Send token to Sentry for debugging purposes

This commit is contained in:
Greg Karékinian
2015-09-29 17:47:09 +02:00
parent 6f3b688b84
commit ad687839b0
4 changed files with 29 additions and 9 deletions

View File

@@ -317,19 +317,27 @@ module RemoteStorage
end
def do_put_request(url, data, content_type)
RestClient.put(url, data, default_headers.merge({content_type: content_type}))
deal_with_unauthorized_requests do
RestClient.put(url, data, default_headers.merge({content_type: content_type}))
end
end
def do_get_request(url, &block)
RestClient.get(url, default_headers, &block)
deal_with_unauthorized_requests do
RestClient.get(url, default_headers, &block)
end
end
def do_head_request(url, &block)
RestClient.head(url, default_headers, &block)
deal_with_unauthorized_requests do
RestClient.head(url, default_headers, &block)
end
end
def do_delete_request(url)
RestClient.delete(url, default_headers)
deal_with_unauthorized_requests do
RestClient.delete(url, default_headers)
end
end
def escape(url)
@@ -367,5 +375,18 @@ module RemoteStorage
settings.swift_token
end
def deal_with_unauthorized_requests(&block)
begin
block.call
rescue RestClient::Unauthorized => ex
Raven.capture_exception(
ex,
tags: { swift_token: settings.swift_token,
swift_token_loaded_at: settings.swift_token_loaded_at }
)
server.halt 500
end
end
end
end