Table of Contents
When exception raised, Basolato will catch excepton and return Exception status response.
raise newException(Error403, "session timeout")
It return 403 response
and 'session timeout' will be in response body.
Basolato have all response status exception type from 300
to 505
List of HTTP Status
If session id is invalid then you want to redirect and delete cookie, raise ErrorAuthRedirect
exception.
if not newAuth(request).isLogin():
raise newException(ErrorAuthRedirect, "/login")
If you want to redirect when error raised, you can use errorRedirect
proc.
This proc is able to used only in controller
or middleware
.
errorRedirect("/login")
These raised exception is caught in framework routing
main.nim
routes:
# Framework
error Http404: http404Route
error Exception: exceptionRoute
Basolate have it's own error page. If you set arg which is path to HTML file in http404Route
and exceptionRoute
, you can display custom error page.
main.nim
routes:
# Framework
error Http404:
http404Route("errors/original404.html")
error Exception:
exceptionRoute("errors/originalError.html")
This path should be related path from resources
dir.
└── resources
└── errors
├── original404.html # user custom error
└── originalError.html # user custom error