Skip to content
sern

Error handling

Error handling is important in any application, especially one which has a long lifetime of running.

Handling errors in command and event modules

To capture errors, enable the ‘error’ event in sern’s global event manager.

  • Directorysrc/
    • Directorycommands/
    • Directoryevents/
      • error.js
    • index.js
    • config.js
    • dependencies.d.ts
1
import { EventType, eventModule } from '@sern/handler'
2
3
export default eventModule({
4
type: EventType.Sern,
5
name: 'error',
6
execute: (err) => {
7
console.log('caught', err)
8
}
9
})

If the error handler is not set, sern’s behavior is to crash the application. This respects node.js’s default behavior