iijlab / direct-hs

Client library for https://direct4b.com in Haskell
8 stars 1 forks source link

Improve exception-handling #23

Closed igrep closed 6 years ago

igrep commented 6 years ago
  1. Make a policy for exception-handling:
    • Public APIs return explicitly IO (Either Exception a). To make them handlable by users and alert users by their documents.
    • Internal, and automatically called APIs throwIO-s. Because they are a bit hard to handle, and they should usually be successful without exceptions.
  2. Add methodName field to UnexpectedReponse data constructor
    • To clarify which RPC calling throws an exception.
    • Would help detecting the cause without stack traces.
  3. Refacor the verbose void $ rethrowingException-s with the new callRpcThrow function.
  4. Avoid incomplete pattern-matches to throw the errors as Web.Direct.Exception.Exception as much as possible.
kazu-yamamoto commented 6 years ago

Merged.