File tree Expand file tree Collapse file tree
adminforth/documentation/docs/tutorial Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,3 +70,27 @@ AF_LOG_SINGLE_LINE=true pnpm start
7070
7171Accepted truthy values are ` true ` and ` 1 ` . When unset, logs use the default multi-line pretty format.
7272
73+ ## Catching unhandled API handler errors
74+
75+ When an unhandled error is thrown inside an AdminForth API endpoint handler (built-in or custom), AdminForth logs the
76+ error and responds with ` 500 Internal server error ` . If you also want to forward these errors somewhere — for example
77+ to report them to an external error-tracking service like [ Sentry] ( https://sentry.io/ ) , or to do your own custom
78+ logging — set the ` expressErrorCallback ` option in your AdminForth config:
79+
80+ ``` ts
81+ import AdminForth from ' adminforth' ;
82+ import * as Sentry from ' @sentry/node' ;
83+
84+ export const admin = new AdminForth ({
85+ // ...rest of your config
86+ expressErrorCallback : ({ error , extra , adminforth }) => {
87+ Sentry .captureException (error , {
88+ extra: {
89+ requestUrl: extra .requestUrl ,
90+ query: extra .query ,
91+ },
92+ });
93+ },
94+ });
95+ ```
96+
You can’t perform that action at this time.
0 commit comments