3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/openpay/errors/openpay_exception_factory.rb', line 3
def OpenpayExceptionFactory::create(exception)
LOG.warn("An exception has been raised (original exception class: #{exception.class})")
case exception
when RestClient::BadRequest, RestClient::ResourceNotFound,
RestClient::Conflict, RestClient::PaymentRequired,
RestClient::UnprocessableEntity
oe=OpenpayTransactionException.new exception.http_body
LOG.warn "-OpenpayTransactionException: #{exception.http_body}"
@errors=true
raise oe
when Errno::EADDRINUSE, Errno::ETIMEDOUT, OpenSSL::SSL::SSLError
oe=OpenpayConnectionException.new(exception.message,false)
LOG.warn exception.message
@errors=true
raise oe
when RestClient::BadGateway, RestClient::Unauthorized, RestClient::RequestTimeout
LOG.warn exception
if exception.http_body
oe=OpenpayConnectionException.new exception.http_body
else
oe=OpenpayConnectionException.new(exception.message, false)
end
@errors=true
raise oe
when RestClient::Exception , RestClient::InternalServerError
LOG.warn exception
if exception.http_body
oe=OpenpayException.new exception.http_body
else
oe=OpenpayException.new(exception.message, false)
end
@errors=true
raise oe
else
LOG.warn exception.message
raise exception
end
end
|