Closed ybelenko closed 3 years ago
It's pretty easy to deduce that information looking at the implementation of HttpMethodNotAllowedException
and HttpNotFoundException
:
class HttpMethodNotAllowedException extends HttpSpecializedException
{
/**
* @var string[]
*/
protected $allowedMethods = [];
/**
* @var int
*/
protected $code = 405;
/**
* @var string
*/
protected $message = 'Method not allowed.';
protected $title = '405 Method Not Allowed';
protected $description = 'The request method is not supported for the requested resource.';
}
class HttpNotFoundException extends HttpSpecializedException
{
/**
* @var int
*/
protected $code = 404;
/**
* @var string
*/
protected $message = 'Not found.';
protected $title = '404 Not Found';
protected $description = 'The requested resource could not be found. Please verify the URI and try again.';
}
It's not documented as these are used internally. I agree that we probably should document them as people can extend HttpSpecializedException
and throw them within their own application for their own special purpose.
I created an issue if someone wants to pick it up: https://github.com/slimphp/Slim/issues/3072
I'm a bit confused with error rendering in Slim4.
You extended
\Exception
with new propstitle
,description
in\Slim\Exception\HttpException
. There are no docs about these props, so by name itself I considerdescription
is debug information andtitle
is mainly a prop for something like 'Ooops, something went wrong'. Still don't know what should I pass into inheritedmessage
prop. It would be nice to get some help with what exception props are rendered and when.After a small investigation of source code:
HtmlErrorRenderer
$displayErrorDetails
is ondisplayErrorDetails
is offJsonErrorRenderer
$displayErrorDetails
is onPlainTextErrorRenderer
$displayErrorDetails
is onXmlErrorRenderer
$displayErrorDetails
is onSo it's not really obvious when to use
description
property since I can see it only withHtmlErrorRenderer
withdisplayErrorDetails
is off which is even more weird for development.