Commit 4ea3668a authored by Bruno Nocera Zanette's avatar Bruno Nocera Zanette

add Default Error handler to Resources

parent c2490324
......@@ -5,6 +5,7 @@ module Dspace
resources do
default_handler(400) { raise InvalidTokenError, 'Invalid access token.' }
default_handler(403) { raise InvalidCredentialsError, 'Wrong Dspace credentials.' }
default_handler { |response| raise StandardError, "#{response}" }
action :login, 'POST /rest/login' do
body { |email, password| JSON.generate({email: email, password: password}) }
......
......@@ -4,6 +4,7 @@ module Dspace
resources do
default_handler(401) { raise NotAuthorizedError, 'This request requires authentication' }
default_handler { |response| raise StandardError, "#{response}" }
action :all, 'GET /rest/bitstreams' do
query_keys :expand, :limit, :offset
......
......@@ -4,6 +4,7 @@ module Dspace
resources do
default_handler(401) { raise NotAuthorizedError, 'This request requires authentication' }
default_handler { |response| raise StandardError, "#{response}" }
action :all, 'GET /rest/collections' do
query_keys :expand, :limit, :offset
......@@ -47,4 +48,4 @@ module Dspace
end
end
end
end
\ No newline at end of file
end
......@@ -4,6 +4,7 @@ module Dspace
resources do
default_handler(401) { raise NotAuthorizedError, 'This request requires authentication' }
default_handler { |response| raise StandardError, "#{response}" }
action :all, 'GET /rest/communities' do
query_keys :expand, :limit, :offset
......
......@@ -4,6 +4,7 @@ module Dspace
resources do
default_handler(401) { raise NotAuthorizedError, 'This request requires authentication' }
default_handler { |response| raise StandardError, "#{response}" }
action :all, 'GET /rest/items' do
query_keys :expand, :limit, :offset
......
......@@ -3,6 +3,7 @@ module Dspace
class StatusResource < ResourceKit::Resource
resources do
default_handler { |response| raise StandardError, "#{response}" }
action :test, 'GET /rest/test' do
handler(200, 201) { |response| true }
......@@ -13,7 +14,7 @@ module Dspace
end
end
end
end
end
\ No newline at end of file
end
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