Skip to content

Commit

Permalink
Add JSON responses for 404 and 500 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mistydemeo committed Aug 20, 2012
1 parent b4e276b commit f808389
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions app.rb
Expand Up @@ -84,10 +84,26 @@

not_found do
status 404
erb :'404'
if not json_requested?
erb :'404'
else
content_type :json
{
"code" => 404,
"error" => "The requested page could not be found."
}.to_json
end
end

error do
status 500
erb :internal_error
if not json_requested?
erb :internal_error
else
content_type :json
{
"code" => 500,
"error" => "An unspecified error occurred."
}.to_json
end
end

0 comments on commit f808389

Please sign in to comment.