refactor: Sort error types
Signed-off-by: Wolfgang Walther <walther@technowledgy.de>
This commit is contained in:
committed by
Wolfgang Walther
parent
927ff6f1e5
commit
8980b09419
+35
-35
@@ -55,20 +55,20 @@ class (JSON.ToJSON a) => PgrstError a where
|
|||||||
errorResponseFor err = responseLBS (status err) (headers err) $ errorPayload err
|
errorResponseFor err = responseLBS (status err) (headers err) $ errorPayload err
|
||||||
|
|
||||||
instance PgrstError ApiRequestError where
|
instance PgrstError ApiRequestError where
|
||||||
status InvalidRange = HTTP.status416
|
status ActionInappropriate = HTTP.status405
|
||||||
status InvalidFilters = HTTP.status405
|
status AmbiguousRelBetween{} = HTTP.status300
|
||||||
status (InvalidBody _) = HTTP.status400
|
status AmbiguousRpc{} = HTTP.status300
|
||||||
status UnsupportedVerb = HTTP.status405
|
status ContentTypeError{} = HTTP.status415
|
||||||
status ActionInappropriate = HTTP.status405
|
status InvalidBody{} = HTTP.status400
|
||||||
status (ParseRequestError _ _) = HTTP.status400
|
status InvalidFilters = HTTP.status405
|
||||||
status (QueryParamError _) = HTTP.status400
|
status InvalidRange = HTTP.status416
|
||||||
status NoRelBetween{} = HTTP.status400
|
status NoRelBetween{} = HTTP.status400
|
||||||
status AmbiguousRelBetween{} = HTTP.status300
|
status NoRpc{} = HTTP.status404
|
||||||
status (AmbiguousRpc _) = HTTP.status300
|
status NotEmbedded{} = HTTP.status400
|
||||||
status NoRpc{} = HTTP.status404
|
status ParseRequestError{} = HTTP.status400
|
||||||
status (UnacceptableSchema _) = HTTP.status406
|
status QueryParamError{} = HTTP.status400
|
||||||
status (ContentTypeError _) = HTTP.status415
|
status UnacceptableSchema{} = HTTP.status406
|
||||||
status (NotEmbedded _) = HTTP.status400
|
status UnsupportedVerb = HTTP.status405
|
||||||
|
|
||||||
headers _ = [ContentType.toHeader CTApplicationJSON]
|
headers _ = [ContentType.toHeader CTApplicationJSON]
|
||||||
|
|
||||||
@@ -270,41 +270,41 @@ checkIsFatal _ = Nothing
|
|||||||
|
|
||||||
|
|
||||||
data Error
|
data Error
|
||||||
= GucHeadersError
|
= ApiRequestError ApiRequestError
|
||||||
| GucStatusError
|
|
||||||
| BinaryFieldError ContentType
|
| BinaryFieldError ContentType
|
||||||
|
| GucHeadersError
|
||||||
|
| GucStatusError
|
||||||
|
| JwtTokenInvalid Text
|
||||||
|
| JwtTokenMissing
|
||||||
|
| JwtTokenRequired
|
||||||
| NoSchemaCacheError
|
| NoSchemaCacheError
|
||||||
|
| NotFound
|
||||||
|
| PgErr PgError
|
||||||
| PutMatchingPkError
|
| PutMatchingPkError
|
||||||
| PutRangeNotAllowedError
|
| PutRangeNotAllowedError
|
||||||
| JwtTokenMissing
|
|
||||||
| JwtTokenInvalid Text
|
|
||||||
| JwtTokenRequired
|
|
||||||
| SingularityError Integer
|
| SingularityError Integer
|
||||||
| NotFound
|
|
||||||
| ApiRequestError ApiRequestError
|
|
||||||
| PgErr PgError
|
|
||||||
|
|
||||||
instance PgrstError Error where
|
instance PgrstError Error where
|
||||||
|
status (ApiRequestError err) = status err
|
||||||
|
status BinaryFieldError{} = HTTP.status406
|
||||||
status GucHeadersError = HTTP.status500
|
status GucHeadersError = HTTP.status500
|
||||||
status GucStatusError = HTTP.status500
|
status GucStatusError = HTTP.status500
|
||||||
status (BinaryFieldError _) = HTTP.status406
|
status JwtTokenInvalid{} = HTTP.unauthorized401
|
||||||
status NoSchemaCacheError = HTTP.status503
|
|
||||||
status PutMatchingPkError = HTTP.status400
|
|
||||||
status PutRangeNotAllowedError = HTTP.status400
|
|
||||||
status JwtTokenMissing = HTTP.status500
|
status JwtTokenMissing = HTTP.status500
|
||||||
status (JwtTokenInvalid _) = HTTP.unauthorized401
|
|
||||||
status JwtTokenRequired = HTTP.unauthorized401
|
status JwtTokenRequired = HTTP.unauthorized401
|
||||||
status (SingularityError _) = HTTP.status406
|
status NoSchemaCacheError = HTTP.status503
|
||||||
status NotFound = HTTP.status404
|
status NotFound = HTTP.status404
|
||||||
status (PgErr err) = status err
|
status (PgErr err) = status err
|
||||||
status (ApiRequestError err) = status err
|
status PutMatchingPkError = HTTP.status400
|
||||||
|
status PutRangeNotAllowedError = HTTP.status400
|
||||||
|
status SingularityError{} = HTTP.status406
|
||||||
|
|
||||||
headers (SingularityError _) = [ContentType.toHeader CTSingularJSON]
|
headers (ApiRequestError err) = headers err
|
||||||
headers (JwtTokenInvalid m) = [ContentType.toHeader CTApplicationJSON, invalidTokenHeader m]
|
headers (JwtTokenInvalid m) = [ContentType.toHeader CTApplicationJSON, invalidTokenHeader m]
|
||||||
headers JwtTokenRequired = [ContentType.toHeader CTApplicationJSON, requiredTokenHeader]
|
headers JwtTokenRequired = [ContentType.toHeader CTApplicationJSON, requiredTokenHeader]
|
||||||
headers (PgErr err) = headers err
|
headers (PgErr err) = headers err
|
||||||
headers (ApiRequestError err) = headers err
|
headers SingularityError{} = [ContentType.toHeader CTSingularJSON]
|
||||||
headers _ = [ContentType.toHeader CTApplicationJSON]
|
headers _ = [ContentType.toHeader CTApplicationJSON]
|
||||||
|
|
||||||
instance JSON.ToJSON Error where
|
instance JSON.ToJSON Error where
|
||||||
toJSON GucHeadersError = JSON.object [
|
toJSON GucHeadersError = JSON.object [
|
||||||
|
|||||||
@@ -83,11 +83,16 @@ data Payload
|
|||||||
|
|
||||||
data InvokeMethod = InvHead | InvGet | InvPost deriving Eq
|
data InvokeMethod = InvHead | InvGet | InvPost deriving Eq
|
||||||
-- | Types of things a user wants to do to tables/views/procs
|
-- | Types of things a user wants to do to tables/views/procs
|
||||||
data Action = ActionCreate | ActionRead{isHead :: Bool}
|
data Action
|
||||||
| ActionUpdate | ActionDelete
|
= ActionCreate
|
||||||
| ActionSingleUpsert | ActionInvoke InvokeMethod
|
| ActionRead {isHead :: Bool}
|
||||||
| ActionInfo | ActionInspect{isHead :: Bool}
|
| ActionUpdate
|
||||||
deriving Eq
|
| ActionDelete
|
||||||
|
| ActionSingleUpsert
|
||||||
|
| ActionInvoke InvokeMethod
|
||||||
|
| ActionInfo
|
||||||
|
| ActionInspect {isHead :: Bool}
|
||||||
|
deriving Eq
|
||||||
-- | The path info that will be mapped to a target (used to handle validations and errors before defining the Target)
|
-- | The path info that will be mapped to a target (used to handle validations and errors before defining the Target)
|
||||||
data Path
|
data Path
|
||||||
= PathInfo
|
= PathInfo
|
||||||
|
|||||||
@@ -59,19 +59,19 @@ import Protolude
|
|||||||
|
|
||||||
data ApiRequestError
|
data ApiRequestError
|
||||||
= ActionInappropriate
|
= ActionInappropriate
|
||||||
| InvalidRange
|
|
||||||
| InvalidBody ByteString
|
|
||||||
| ParseRequestError Text Text
|
|
||||||
| QueryParamError QPError
|
|
||||||
| NoRelBetween Text Text Text
|
|
||||||
| AmbiguousRelBetween Text Text [Relationship]
|
| AmbiguousRelBetween Text Text [Relationship]
|
||||||
| AmbiguousRpc [ProcDescription]
|
| AmbiguousRpc [ProcDescription]
|
||||||
| NoRpc Text Text [Text] Bool ContentType Bool
|
|
||||||
| InvalidFilters
|
|
||||||
| UnacceptableSchema [Text]
|
|
||||||
| ContentTypeError [ByteString]
|
| ContentTypeError [ByteString]
|
||||||
| UnsupportedVerb -- Unreachable?
|
| InvalidBody ByteString
|
||||||
|
| InvalidFilters
|
||||||
|
| InvalidRange
|
||||||
|
| NoRelBetween Text Text Text
|
||||||
|
| NoRpc Text Text [Text] Bool ContentType Bool
|
||||||
| NotEmbedded Text
|
| NotEmbedded Text
|
||||||
|
| ParseRequestError Text Text
|
||||||
|
| QueryParamError QPError
|
||||||
|
| UnacceptableSchema [Text]
|
||||||
|
| UnsupportedVerb -- Unreachable?
|
||||||
|
|
||||||
data QPError = QPError Text Text
|
data QPError = QPError Text Text
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user