Customizable error messages output #747
-
Salute! \0 I need to change the default template of error messages like {
"error": {
"code": 403,
"status": "Forbidden",
"message": "Access credentials are not sufficient to access this resource"
}
} to my own. During the investigation I found this thread where Arthur already asked the same question. Further, the issue was resolved by hackerman in this commit where he added customizable error handlers. I took a glance to the code he wrote, read the documentation & tried to figured out how these changes can help me to solve the problem, but I still don't get it. So, is it even possible to change the body of an error output? E.g. do something like this in the config file: errors:
fallback:
- json
handlers:
json:
enabled: true
config:
error_template: file:///path/to/my-error-template.json If Arthur's issue was closed then I assume that it is possible to do.. somehow. I also found this article where Daniel have error responses like this one: {
"error": {
"code": 404,
"status": "Not Found",
"request": "84a2b164-7229-4f69-a0cd-227611c07128",
"message": "Requested url does not match any rules"
}
} and because of the BTW if it's not possible yet, I already tried to achieve this in a different way - with the errors:
fallback:
- redirect
handlers:
redirect:
enabled: true
config:
to: https://my.domain.com/403.json Finally, It allowed me to get the output of an error message I wanted to, but there are also some problems with it:
{
"message": "Operation not allowed",
"code": 403,
"errors": []
}
errors:
fallback:
- redirect
handlers:
redirect:
enabled: true
config:
when:
- error: forbidden
to: https://my.domain.com/403.json
- error: not_found
to: https://my.domain.com/404.json Neither the documentation nor different keyword combinations, permutations, indents helped me. It just doesn't work. ¯\(ツ)/¯ |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey @5aboteur, To quote:
Let me know if that helps! 🐝 |
Beta Was this translation helpful? Give feedback.
Hey @5aboteur,
is your use case related to this: ory/kratos#1348 ?
To quote:
Let me know if that helps! 🐝