The corresponding handler function uses the
Envelope
data type to model the possibility of returning an Author successfully, or
either DatabaseError or AuthorNotFoundError unsuccessfully.
Internally, Envelope is using an open sum-type to easily represent multiple
different errors:

We are able to reuse the DatabaseError and AuthorNotFoundError. If we try
to return an error that is not declared using Throws, GHC will give us an
error. We get flexiblity and type-safety.

When using servant-docs to
create documentation, only one instance of ToSample needs to be created for
each error (DatabaseError, AuthorNotFoundError, and AuthorNameTooShort).
Multiple instances of ToSample do not need to be created for every
different Envelope used in a handler.

Packaging the core types

servant-checked-exceptions-core
exports the core types need for building an API with checked exceptions,
allowing you to avoid depending on server-side libraries like warp, Glob
and servant-server. This can be useful if you are writing an API meant to be
shared with ghcjs and run in a browser, where these dependencies aren’t
available.

Changes

2.0.0.0

Split into two package servant-checked-exceptions-core and
servant-checked-exceptions. The former defines the core types
and functions for using checked exceptions in a servant API;
the latter reexports the former and adds instances for HasServer
and HasClient. The rationale is described further in
issue 25

Most users should only depend on servant-checked-exceptions.
But users who need access to core types without incurring a dependency
on servant-server and servant-client can depend on
servant-checked-exceptions-core instead.

Split Exceptions module into Envelope and Verbs in
servant-checked-exceptions-core, for better module organization.
More information in
issue 18

1.1.0.0

Updated the servant dependency to >= 0.12.

1.0.0.0

Add a ErrStatus class that can be used to set the HTTP Status Code. Given
an endpoint that returns a Envelope '[e1, e2] a, you must declare an
instance of ErrStatus for e1 and e2. This is a breaking change.

0.4.1.0

Add NoThrow type to represent handlers that don’t throw any errors, but
do return a result wrapped in an Envelope.