Skip to content

Commit

Permalink
move ErrorHandler note to best practices
Browse files Browse the repository at this point in the history
  • Loading branch information
angryziber committed Dec 20, 2023
1 parent 7fdbbe4 commit 453e0e0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ The order is important, and decorators apply to all *following routes* that are
Any exception thrown out of route handler will be passed to [ErrorHandler](src/klite/ErrorHandler.kt) to produce a response.
The [ErrorResponse](src/klite/ErrorHandler.kt) is then passed to [BodyRenderer](src/klite/Body.kt), like normal responses.

Do not catch common exceptions in your route handlers, but add global error handlers instead based on Exception type.

## Sessions

Session support can be enabled by providing a [SessionStore](src/klite/Session.kt) implementation, e.g.
Expand Down Expand Up @@ -125,3 +123,4 @@ Enable these only if you are sure that you will be running behind a trusted prox
* Organize your code into domain packages, e.g. `payments`, `accounting`, and not by type of class, e.g. `controllers`, `repostories`, `services`, etc.
* Route handler's job is to parse the request, call a service method and transform/return the result. It should not implement business logic itself.
* Prefer annotated route handlers for easier code separation and unit testing.
* Do not catch common exceptions in your route handlers, but use `ErrorHandler.on` to add a global error handler instead based on Exception type, reducing code duplication.

0 comments on commit 453e0e0

Please sign in to comment.