Hi everybody!
I was playing with the ORM and a REST Controller, and I stumble into an issue.
Even if I specify the httpcode for the response, the ORM will override it on failure.
example: $this->response('',500);
on success I don't have any issue.
Does anyone have any Idea?
(you can see the code below)
Thanks!
I fail to see the relationship between the ORM and an HTTP status code.
If an ORM method call fails, and you catch the exception thrown, you can do with it what you want. If you don't catch it (either because you didn't code the catch, or you made an mistake), you'll end up with an error generated by the framework, which will set a 500 status code unless HTTP headers are already sent.
Note however that the rest controller will set a 404 status if either the method requested does not exist, or if there is no data to be returned (and that seems to be the case if your ORM call fails).
If you want a 500 status code instead, set the $no_data_status property of your REST controller to 500.