Commit f2f3bfc7 authored by John E. Vincent's avatar John E. Vincent

cleanup/DRY/exception handling changes

parent 54564437
This diff is collapsed.
...@@ -7,8 +7,9 @@ require File.join(File.dirname(__FILE__), 'app') ...@@ -7,8 +7,9 @@ require File.join(File.dirname(__FILE__), 'app')
set :env, :development set :env, :development
set :root, File.dirname(__FILE__) set :root, File.dirname(__FILE__)
set :server, %[thin mongrel webrick] set :server, %[thin mongrel webrick]
set :logging, true if development? set :logging, true
set :raise_errors, true if development? set :raise_errors, false
set :show_exceptions, false
disable :run disable :run
run Sinatra::Application run Sinatra::Application
...@@ -16,13 +16,21 @@ helpers do ...@@ -16,13 +16,21 @@ helpers do
end end
def host_service(hostname, servicename) def host_service(hostname, servicename)
id = Host.find(:name => hostname).first.id h = Host.find(:name => hostname).first
Service.find(:host_id => id, :name => servicename).first if h.nil?
nil
else
Service.find(:host_id => h.id, :name => servicename).first
end
end end
def host_services(hostname) def host_services(hostname)
id = Host.find(:name => hostname).first.id h = Host.find(:name => hostname).first
Services.all(:host_id => id) if h.nil?
nil
else
Services.all(:host_id => id)
end
end end
def application(opts = {}) def application(opts = {})
......
{
"result":"failure",
"error_message":"Resource not found"
}
{
"result":"failure",
"error_message":"<%= request.env['sinatra.error'].message %>"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment