fb_graph 2.7.4 → 2.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/fb_graph/exception.rb +24 -30
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e20936fbb91e27922ff9874b566a4f78a3201e5e
|
4
|
+
data.tar.gz: 9da3bbe4f289352bf7d92a643c9a19868c12bd2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35c2ed6ba348711f3ec21d97e5e94a131a729f9523674d51ff0ac817ce7d974157bd4bfbb31e5d5b8be20e3cb7ed4403b9e19c3821fad0e33594aefeb213f1f5
|
7
|
+
data.tar.gz: cc3744711324d626bbdea392fd8239ba12b4648717e4e178643bc2d6368495067ac6bcee4d709991a46bfe60aa3ae4733e8099f9af52f16d665b03abaedcddac
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.7.
|
1
|
+
2.7.5
|
data/lib/fb_graph/exception.rb
CHANGED
@@ -3,42 +3,18 @@ module FbGraph
|
|
3
3
|
attr_accessor :status, :type, :error_code, :error_subcode
|
4
4
|
alias_method :code, :status
|
5
5
|
|
6
|
-
ERROR_HEADER_MATCHERS = {
|
7
|
-
/not_found/ => "NotFound",
|
8
|
-
/invalid_token/ => "InvalidToken",
|
9
|
-
/invalid_request/ => "InvalidRequest"
|
10
|
-
}
|
11
|
-
|
12
|
-
ERROR_EXCEPTION_MATCHERS = {
|
13
|
-
/Could\snot\ssave\screative/ => "CreativeNotSaved",
|
14
|
-
/QueryLockTimeoutException/ => "QueryLockTimeout",
|
15
|
-
/Could\snot\screate\stargeting\sspec/ => "TargetingSpecNotSaved",
|
16
|
-
/Could\snot\sfetch\sadgroups/ => "AdgroupFetchFailure",
|
17
|
-
/Failed\sto\sopen\sprocess/ => "OpenProcessFailure",
|
18
|
-
/Could\snot\scommit\stransaction/ => "TransactionCommitFailure",
|
19
|
-
/QueryErrorException/ => "QueryError",
|
20
|
-
/QueryConnectionException/ => "QueryConnection",
|
21
|
-
/QueryDuplicateKeyException/ => "QueryDuplicateKey"
|
22
|
-
}
|
23
|
-
|
24
6
|
class << self
|
25
7
|
def handle_structured_response(status, details, headers)
|
26
8
|
if (error = details[:error])
|
27
9
|
klass = klass_for_header(headers, error) || klass_for_structured_body(error)
|
28
|
-
message = [
|
29
|
-
error[:type] || 'unknown error type',
|
30
|
-
error[:message] || 'unknown error message'
|
31
|
-
].join(' :: ')
|
10
|
+
message = [error[:type], error[:message]].join(' :: ')
|
32
11
|
if klass
|
33
12
|
raise klass.new(message, details)
|
34
13
|
else
|
35
14
|
handle_response status, message, details
|
36
15
|
end
|
37
16
|
else
|
38
|
-
message = [
|
39
|
-
details[:error_code] || 'unknown error_code',
|
40
|
-
details[:error_msg] || 'unknown error_msg'
|
41
|
-
].compact.join(' :: ')
|
17
|
+
message = [details[:error_code], details[:error_msg]].compact.join(' :: ')
|
42
18
|
handle_response status, message, details
|
43
19
|
end
|
44
20
|
end
|
@@ -73,10 +49,10 @@ module FbGraph
|
|
73
49
|
if value =~ /invalid_token/ && error[:message] =~ /session has been invalidated/
|
74
50
|
InvalidSession
|
75
51
|
else
|
76
|
-
matched,
|
52
|
+
matched, klass = ERROR_HEADER_MATCHERS.detect do |matcher, klass_name|
|
77
53
|
matcher =~ value
|
78
54
|
end || return
|
79
|
-
|
55
|
+
klass
|
80
56
|
end
|
81
57
|
end
|
82
58
|
|
@@ -85,10 +61,10 @@ module FbGraph
|
|
85
61
|
when /OAuth/
|
86
62
|
Unauthorized
|
87
63
|
else
|
88
|
-
matched,
|
64
|
+
matched, klass = ERROR_EXCEPTION_MATCHERS.detect do |matcher, klass_name|
|
89
65
|
matcher =~ error[:message]
|
90
66
|
end || return
|
91
|
-
|
67
|
+
klass
|
92
68
|
end
|
93
69
|
end
|
94
70
|
end
|
@@ -140,4 +116,22 @@ module FbGraph
|
|
140
116
|
class QueryError < InternalServerError; end
|
141
117
|
class QueryConnection < InternalServerError; end
|
142
118
|
class QueryDuplicateKey < InternalServerError; end
|
119
|
+
|
120
|
+
ERROR_HEADER_MATCHERS = {
|
121
|
+
/not_found/ => NotFound,
|
122
|
+
/invalid_token/ => InvalidToken,
|
123
|
+
/invalid_request/ => InvalidRequest
|
124
|
+
}
|
125
|
+
|
126
|
+
ERROR_EXCEPTION_MATCHERS = {
|
127
|
+
/Could\snot\ssave\screative/ => CreativeNotSaved,
|
128
|
+
/QueryLockTimeoutException/ => QueryLockTimeout,
|
129
|
+
/Could\snot\screate\stargeting\sspec/ => TargetingSpecNotSaved,
|
130
|
+
/Could\snot\sfetch\sadgroups/ => AdgroupFetchFailure,
|
131
|
+
/Failed\sto\sopen\sprocess/ => OpenProcessFailure,
|
132
|
+
/Could\snot\scommit\stransaction/ => TransactionCommitFailure,
|
133
|
+
/QueryErrorException/ => QueryError,
|
134
|
+
/QueryConnectionException/ => QueryConnection,
|
135
|
+
/QueryDuplicateKeyException/ => QueryDuplicateKey
|
136
|
+
}
|
143
137
|
end
|