FOSRestBundle: MethodNotAllowedException is not caught
Hi all,
I’ve the following configuration:
product_option_create:
pattern: /create.{_format}
defaults:
_format: ~
_controller: colibri_product.controller.option:createAction
requirements:
_method: POST
twig:
exception_controller: 'FOS\RestBundle\Controller\ExceptionController::showAction'
Accessing option/create.json, results in:

There is some way to handle this exception properly?
I was expecting something like:
{
"status":"error",
"status_code":405,
"status_text":"Method Not Allowed",
"current_content":"",
"message":"Method Not Allowed (Allow: POST)"
}
Thanks in advance.
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 32 (14 by maintainers)
If anyone has the same issue in the future, this is what I did:
I created a custom Exception controller that extends this bundle’s controller and then override the showAction method.
Don’t forget to change the configuration setttings (config.yml)