Improves error handling on the server

Started using npm 'errors' package to provide custom errors as well as a consistent way to define errors.