I just need to ask is octobercms has only capable of setting two types of errors ???
404 [by creating a page with /404 url ]
500 [by creating a page with /error url ]
how can we set 400, 401, 402, 403, 503, 400 etc ??????
Those 2 are special cases where author already wrote code in Cms Main Controller
but for others we need to write code on our own :)
Hmm all are related to HttpException
so this are the codes actually we set and throw like this,
App::abort(403, 'Access is forbidden to the requested page.' /* message */);
Now these all are HttpException
, We can intercept them using App::error
. You need to add this code to your plugin boot
method.
//\App::error(function(\Exception $exception) { // for handling all Exceptions
// for handling http related exceptions
\App::error(function(
\Symfony\Component\HttpKernel\Exception\HttpException $exception) {
dd($exception->getStatusCode()); /* 403 */ // 400, 401, 402, 403, 503, 400 etc
// Handle the exception...
});
You can check status-code
here and handle them as you like.
Reference: https://octobercms.com/docs/services/error-log#http-exceptions