When an error returns and an ApiPie exception is raised, since it's a custom error and no one catches it, HTTP error 500 returns, which is wrong (http error 500 is internal server error - it should be 400, like rails bad request
A simple solution would be to add something like this to the Errors class:
module RescueError
def self.included(base)
base.rescue_from Apipie::Error do |e|
# render "public/404", :status => 404
respond_to do |format|
format.html { render :show, status: @status_code, layout: !request.xhr? }
format.xml { render xml: e, root: "error", status: 400 }
format.json { render json: {error: e}, status: 400 }
end
end
end
end
then change the docs to ask people to add include Apipie::RescueError to the base controller or the Api base controller, whatever they use.
What do you think? If approved I'll send a pull request
Great, this saved my life; thanks!; i wonder why by design the apipie returns an error 500 on production mode instead of a nice description like in dev?
Hi,
When an error returns and an ApiPie exception is raised, since it's a custom error and no one catches it, HTTP error 500 returns, which is wrong (http error 500 is internal server error - it should be 400, like rails bad request
A simple solution would be to add something like this to the Errors class:
module RescueError
end
then change the docs to ask people to add include Apipie::RescueError to the base controller or the Api base controller, whatever they use.
What do you think? If approved I'll send a pull request