File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -61,14 +61,14 @@ def request(json_request: false, flat_params: false)
61
61
def errors ( response )
62
62
body = response . body
63
63
64
- return parse_errors ( body ) if body . is_a? ( Hash ) && body [ :error ]
64
+ return parse_errors ( body ) unless error_hash ( body ) . nil?
65
65
66
66
[ ]
67
67
end
68
68
69
69
sig { params ( body : T ::Hash [ Symbol , T . any ( String , T ::Array [ String ] ) ] ) . returns ( LunchMoney ::Errors ) }
70
70
def parse_errors ( body )
71
- errors = body [ :error ] || body [ :errors ]
71
+ errors = error_hash ( body )
72
72
return [ ] if errors . blank?
73
73
74
74
api_errors = [ ]
@@ -84,5 +84,18 @@ def parse_errors(body)
84
84
85
85
api_errors
86
86
end
87
+
88
+ sig { params ( body : T . untyped ) . returns ( T . untyped ) }
89
+ def error_hash ( body )
90
+ return unless body . is_a? ( Hash )
91
+
92
+ if body [ :error ]
93
+ body [ :error ]
94
+ elsif body [ :errors ]
95
+ body [ :errors ]
96
+ elsif body [ :name ] == "Error"
97
+ body [ :message ]
98
+ end
99
+ end
87
100
end
88
101
end
You can’t perform that action at this time.
0 commit comments