-
Notifications
You must be signed in to change notification settings - Fork 94
Refactoring guidelines
andrewjstone edited this page Apr 23, 2013
·
4 revisions
- Use idiomatic erlang
- Use consistent calling conventions
- Domain specific code should go in it's 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.
- Keep it minimal!
- Fail fast, but correctly - Follow a few conventions
x * 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.