Skip to content

Commit e5c9281

Browse files
authored
Merge pull request #224 from EasyPost/concatenate_error_message
fix: concatenates error.message if it is an array
2 parents 2d44fa4 + 1673ceb commit e5c9281

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## NEXT RELEASE
44

5+
- Concatenates `error.message` if it incorrectly comes back from the API as an array
56
- Treats any HTTP status outside the `2xx` range as an error. Impact expected is minimal as this change only affects `1xx` and `3xx` HTTP status codes
67

78
## v4.8.0 (2022-09-21)

lib/easypost/error.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ class EasyPost::Error < StandardError
66

77
# Initialize a new EasyPost Error
88
def initialize(message = nil, status = nil, code = nil, errors = nil, http_body = nil)
9-
@message = message
9+
# message should be a string but can sometimes incorrectly come back as an array
10+
@message = message.is_a?(Array) ? message.join(', ') : message
1011
@status = status
1112
@code = code
1213
@errors = errors

spec/error_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,11 @@
2727
# Compare an error and its properties to another error
2828
expect(e).to eq(e.clone)
2929
end
30+
31+
it 'concatenates error.message when it comes back incorrectly as an array from the API' do
32+
error = described_class.new(%w[Error1 Error2])
33+
34+
expect(error.message).to eq('Error1, Error2')
35+
end
3036
end
3137
end

0 commit comments

Comments
 (0)