diff options
author | Christoph Helma <helma@in-silico.ch> | 2011-06-06 16:54:56 +0000 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2011-06-06 16:54:56 +0000 |
commit | dcb32e4271cb1cab70f3669985e8e34c87e3bf23 (patch) | |
tree | 771d65c42dd26962e08bf348efc2847d118dd82e | |
parent | f4893f1ea13bd29d408deef1997c708d0b2129d9 (diff) |
halts (partially) substituted by OpenTox errors
-rw-r--r-- | application.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/application.rb b/application.rb index 4008a74..749dbcc 100644 --- a/application.rb +++ b/application.rb @@ -93,7 +93,7 @@ before do @uri = uri @id @yaml_file = "public/#{@id}.yaml" - halt 404, "Dataset #{@id} not found." unless File.exists? @yaml_file + raise OpenTox::NotFoundError.new "Dataset #{@id} not found." unless File.exists? @yaml_file extension = File.extname(request.path_info) unless extension.empty? @@ -109,7 +109,7 @@ before do when ".xls" @accept = 'application/ms-excel' else - halt 404, "File format #{extension} not supported." + raise OpenTox::NotFoundError.new "File format #{extension} not supported." end end end @@ -162,7 +162,7 @@ get '/:id' do File.open(file).read else - halt 404, "Content-type #{@accept} not supported." + raise OpenTox::NotFoundError.new "Content-type #{@accept} not supported." end end @@ -270,7 +270,7 @@ post '/?' do OpenTox::Authorization.check_policy(@uri, @subjectid) if File.exists? @yaml_file @uri end - halt 503,task.uri+"\n" if task.status == "Cancelled" + raise OpenTox::ServiceUnavailableError.newtask.uri+"\n" if task.status == "Cancelled" halt 202,task.uri+"\n" end end @@ -294,7 +294,7 @@ post '/:id' do load_dataset @id, params, request.content_type, request.env["rack.input"].read @uri end - halt 503,task.uri+"\n" if task.status == "Cancelled" + raise OpenTox::ServiceUnavailableError.newtask.uri+"\n" if task.status == "Cancelled" halt 202,task.uri.to_s+"\n" end @@ -315,7 +315,7 @@ delete '/:id' do response['Content-Type'] = 'text/plain' "Dataset #{@id} deleted." rescue - halt 404, "Dataset #{@id} does not exist." + raise OpenTox::NotFoundError.new "Dataset #{@id} does not exist." end end |