Skip to content

Commit 6ae696e

Browse files
feat: Check class of errors
1 parent 47e11c7 commit 6ae696e

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

lib/barkbox_client/api_error.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@ def initialize(response)
1212
end
1313

1414
def pretty_errors
15-
return @errors if @errors.nil? || @errors.is_a?(String)
16-
17-
@errors.map { |k, v| "#{k} #{v}" }.join(", ")
15+
case @errors
16+
when String
17+
@errors
18+
when Hash
19+
@errors.map { |k, v| "#{k} #{v}" }.join(", ")
20+
when NilClass
21+
"@errors was nil"
22+
else
23+
"Unknown error format: #{@errors}"
24+
end
1825
end
1926

2027
def message

0 commit comments

Comments
 (0)