Description
Using aah v0.12.3
I'm creating a new api project with aah new
I've found an issue when i try to create centralized error handler by creating AppErrorHandler
function and register it in init.go
by following the instruction from
https://docs.aahframework.org/v0.12/error-handling.html#registering-centralized-error-handler
func AppErrorHandler(ctx *aah.Context, err *aah.Error) bool {
switch err.Code {
case 400:
// handle bad request
case 401:
// handle unauthenticated request
case 403:
// handle permission issues
case 500:
// handle internal server issues
}
return true
}
func init() {
app := aah.App()
app.SetErrorHandler(AppErrorHandler)
}
an error occurred when i run it with aah run
:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x8a7974]
goroutine 1 [running]:
aahframe%2ework.(*errorManager).SetHandler(0x0, 0xa29780)
/home/user1/go/pkg/mod/[email protected]/error.go:132 +0x34
aahframe%2ework.(*Application).SetErrorHandler(0xc0001e21c0, 0xa29780)
/home/user1/go/pkg/mod/[email protected]/aah.go:400 +0x3c
main.init.0()
/home/user1/ws_aah/aah-app/app/init.go:43 +0x118
FATAL aah application did not start
Thanks