Skip to content

Commit

Permalink
Add ZeroPagesError as a new subclass of ClientError
Browse files Browse the repository at this point in the history
  • Loading branch information
nanotone committed Mar 5, 2020
1 parent ac7e205 commit 95b90bd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/vbms/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ def initialize(cmd, output)
end
end

class ZeroPagesError < ClientError
end

class BadClaim < HTTPError; end
class BadPostalCode < HTTPError; end
class BadSOAPMessage < HTTPError; end
Expand Down
2 changes: 1 addition & 1 deletion lib/vbms/service/paged_documents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def call(file_number:)
first_page = client.send_request(req)

# interpret a first page with no sections (and no doc count) as equivalent to zero pages.
raise ClientError.new("No sections found in first page") if first_page.empty?
raise ZeroPagesError.new("No sections found in first page") if first_page.empty?

# response will always be an array. get pagination from the first section.
(documents << first_page.map { |section| section[:documents] }).flatten!
Expand Down
4 changes: 2 additions & 2 deletions spec/service/paged_documents_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def next_response
end

context "when the first page contains no sections" do
it "raises a ClientError" do
it "raises a ZeroPagesError" do
allow(client).to receive(:send_request).and_return []
expect { subject.call(file_number: file_number) }.to raise_error(VBMS::ClientError)
expect { subject.call(file_number: file_number) }.to raise_error(VBMS::ZeroPagesError)
end
end
end
Expand Down

0 comments on commit 95b90bd

Please sign in to comment.