Skip to content

Commit 499ae9f

Browse files
authored
Deprecate InvalidEmailAddressError (#134)
## What - Renames `InvalidEmailAddressError` to `InvalidEmailRequestError` - Closes #120 - Related to #119 ## Why This addresses some confusion around this error that can occur for a number of reasons, and not just invalid email addresses, bringing it more in sync with the [API definition](https://postmarkapp.com/developer/api/overview#error-codes) ## How For now this is just a straight rename with an alias provided for backwards compatibility. @tomazy let me know if there's anything you had in mind for this! 🙏
1 parent ef4875c commit 499ae9f

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

CHANGELOG.rdoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
= Changelog
22

3+
== 1.23.0
4+
* Deprecated `InvalidEmailAddressError`. New name is `InvalidEmailRequestError`.
5+
36
== 1.22.3
47
* Increased default timeout values
58

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.22.3
1+
1.23.0

lib/postmark/error.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def retry?
4343

4444
class ApiInputError < HttpServerError
4545
INACTIVE_RECIPIENT = 406
46-
INVALID_EMAIL_ADDRESS = 300
46+
INVALID_EMAIL_REQUEST = 300
4747

4848
attr_accessor :error_code
4949

@@ -53,8 +53,8 @@ def self.build(body, parsed_body)
5353
case error_code
5454
when INACTIVE_RECIPIENT
5555
InactiveRecipientError.new(error_code, body, parsed_body)
56-
when INVALID_EMAIL_ADDRESS
57-
InvalidEmailAddressError.new(error_code, body, parsed_body)
56+
when INVALID_EMAIL_REQUEST
57+
InvalidEmailRequestError.new(error_code, body, parsed_body)
5858
else
5959
new(error_code, body, parsed_body)
6060
end
@@ -70,7 +70,7 @@ def retry?
7070
end
7171
end
7272

73-
class InvalidEmailAddressError < ApiInputError; end
73+
class InvalidEmailRequestError < ApiInputError; end
7474

7575
class InactiveRecipientError < ApiInputError
7676
attr_reader :recipients
@@ -129,4 +129,5 @@ class UnexpectedHttpResponseError < HttpServerError; end
129129
DeliveryError = Error
130130
InvalidMessageError = ApiInputError
131131
UnknownError = UnexpectedHttpResponseError
132+
InvalidEmailAddressError = InvalidEmailRequestError
132133
end

lib/postmark/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Postmark
2-
VERSION = '1.22.3'
2+
VERSION = '1.23.0'
33
end

spec/unit/postmark/error_spec.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@
9898
end
9999

100100
context '300' do
101-
let(:code) {Postmark::ApiInputError::INVALID_EMAIL_ADDRESS}
101+
let(:code) {Postmark::ApiInputError::INVALID_EMAIL_REQUEST}
102102

103-
it {is_expected.to be_a(Postmark::InvalidEmailAddressError)}
103+
it {is_expected.to be_a(Postmark::InvalidEmailRequestError)}
104104
it_behaves_like 'api input error'
105105
end
106106

@@ -149,13 +149,13 @@
149149
it {is_expected.to be_a(Postmark::Error)}
150150
end
151151

152-
describe(Postmark::InvalidEmailAddressError) do
152+
describe(Postmark::InvalidEmailRequestError) do
153153
describe '.new' do
154154
let(:response) {{'Message' => message}}
155155

156156
subject do
157-
Postmark::InvalidEmailAddressError.new(
158-
Postmark::ApiInputError::INVALID_EMAIL_ADDRESS, Postmark::Json.encode(response), response)
157+
Postmark::InvalidEmailRequestError.new(
158+
Postmark::ApiInputError::INVALID_EMAIL_REQUEST, Postmark::Json.encode(response), response)
159159
end
160160

161161
let(:message) do
@@ -171,7 +171,7 @@
171171
end
172172

173173
it 'error code is set' do
174-
expect(subject.error_code).to eq(Postmark::ApiInputError::INVALID_EMAIL_ADDRESS)
174+
expect(subject.error_code).to eq(Postmark::ApiInputError::INVALID_EMAIL_REQUEST)
175175
end
176176
end
177177
end
@@ -274,3 +274,9 @@ def all_recipients_inactive_message(addresses)
274274
expect(subject.class).to eq(Postmark::UnexpectedHttpResponseError)
275275
end
276276
end
277+
278+
describe(Postmark::InvalidEmailAddressError) do
279+
it 'is an alias for backwards compatibility' do
280+
expect(subject.class).to eq(Postmark::InvalidEmailRequestError)
281+
end
282+
end

0 commit comments

Comments
 (0)