You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
andrewjstone edited this page Apr 23, 2013
·
4 revisions
Overall
Use idiomatic erlang
Use consistent calling conventions
Domain specific code should go in its own modules
Domain specific api response modules should return a valid response or error to the client. This includes HTTP error codes, since S3 is non-standard in that respect.
Error Handling
Keep it minimal!
Fail fast, but correctly - Follow a few conventions
Match for the good case
try/catch at the top of the call stack to catch any expected errors and return a 400 level error code.
Only use try/catch at the top of the callstack, unless you need to wrap an unwieldy library to return the proper error format {error, Reason}.
Only try pattern match against errors you expect. Errors you expect should be {badmatch, {error, Reason}}
Unexpected errors are uncaught and will result in webmachine returning a 500 error.