servant-exceptions alternatives and similar packages
Based on the "servant" category.
Alternatively, view servant-exceptions alternatives based on common mentions on social networks and blogs.
-
servant
Main repository for the servant libraries — DSL for describing, serving, querying, mocking, documenting web applications and more! -
servant-elm
Automatically derive Elm functions to query servant webservices -
servant-purescript
Translate servant API to purescript code, with the help of purescript-bridge. -
servant-swagger-ui
Provide embedded swagger UI for servant and swagger -
servant-response
Moved to http://github.com/haskell-servant -
servant-js
Automatically derive javascript functions to query servant webservices. -
servant-auth-cookie
Authentication via encrypted cookies -
servant-router
Servant router for non-server applications. -
servant-aeson-specs
Generically obtain tests for JSON serialization -
servant-pandoc
Render a servant API to Pandoc's native representation -
servant-github-webhook
Servant combinators for writing secure GitHub webhooks -
servant-cli
Generate a command line client from a servant API -
servant-pagination
Type-safe pagination for Servant APIs -
servant-mock
Derive a mock server for free from your servant API types -
servant-matrix-param
Matrix parameter combinator for servant -
servant-auth-token-acid
Servant based API and server for token based authorisation -
servant-auth-token-leveldb
Servant based API and server for token based authorisation -
servant-github
servant types to access the GitHub API v3 -
servant-py
Servant client generators for the Python language -
servant-jsonrpc
Tools to build JSON-RPC clients and servers the Servant way -
servant-reason
Automatically derive bindings for Servant APIs in Reason -
servant-zeppelin-client
Server Side Loading JSON -
servant-http2-client
Generate http2-client from Servant APIs -
servant-kotlin
Automatically derive Kotlin functions to query servant webservices -
servant-ruby
Create a Ruby client from a Servant API using Net::HTTP. -
servant-match
Standalone implementation of servant’s dispatching mechanism -
servant-options
Provide responses to OPTIONS requests for Servant applications. -
servant-generate
Generate default implementations for servers in a flexible way (a.k.a servant-mock on steroids) -
servant-proto-lens
Servant Content-Type for proto-lens protobuf modules. -
servant-haxl-client
automatical derivation of querying functions for servant webservices -
servant-jsonrpc-client
Generate JSON-RPC servant clients -
servant-multipart
multipart/form-data (e.g file upload) support for servant
Static code analysis for 29 languages.
Do you think we are missing an alternative of servant-exceptions or a related project?
README
servant-exceptions 
Servant servers typically run their handlers in some form of IO
. Either directly in the builtin Handler
monad or a custom monad transformer on top it. When APIs fail, one would typically use the MonadError ServantError
instance via throwError
to create an error response of type ServantErr
.
This approach has two problems:
Handler
(basically beingExceptT ServantErr IO
) is considered an anti-pattern by some, as it suggests to novice users that onlyServantErr
would occur, but inIO
any exception can be raised to abort executionServantErr
values need to be created at the call site ofthrowError
, where the requested content type and/or headers are not available
servant-exception
tries to help with both by making it easy to catch specific error types with an instance of Exception
and provide automatic encoding into the requested content-type.
The API combinator Throws e
can be used to catch exceptions of type e
in the server, for example:
type API = "api" :> Throws UsersError :> "users" :> Get '[JSON, PlainText] [User]
The type UsersError
can then be used to describe expected errors and their conversion via type class instances:
data UsersError = UserNotFound
| UserAlreadyExists
| InternalError
deriving (Show)
instance Exception UsersError
instance ToServantErr UsersError where
status UserNotFound = status404
status UserAlreadyExists = status409
status InternalError = status500
instance ToJSON UsersError where
toJSON e = object [ "type" .= show (typeOf e)
, "message" .= message e
]
instance MimeRender PlainText UsersError where
mimeRender ct = mimeRender ct . show
TODO
This package is still a work-in-progress and lacks at least
- Documentation, more examples
servant-client
supportservant-docs
support
Credit
This package is inspired by servant-checked-exceptions
(Throws combinator) and
the generalized error handling in cardano-sl
.