Catch errors thrown by API request handlers

- Ignores the error if called by preloader (otherwise it'd record each error twice)
- Writes them to the error log
- Sends the error to the client in dev mode
- Sends generic message to the client in prod mode
- Fixes #16