From 95b90bd434277bf214caa8446beca275df0a1309 Mon Sep 17 00:00:00 2001 From: Yang Yang Date: Wed, 4 Mar 2020 17:02:39 -0500 Subject: [PATCH] Add ZeroPagesError as a new subclass of ClientError --- lib/vbms/errors.rb | 3 +++ lib/vbms/service/paged_documents.rb | 2 +- spec/service/paged_documents_spec.rb | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/vbms/errors.rb b/lib/vbms/errors.rb index 094f08b..272215f 100644 --- a/lib/vbms/errors.rb +++ b/lib/vbms/errors.rb @@ -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 diff --git a/lib/vbms/service/paged_documents.rb b/lib/vbms/service/paged_documents.rb index d2253b9..2b0bf30 100644 --- a/lib/vbms/service/paged_documents.rb +++ b/lib/vbms/service/paged_documents.rb @@ -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! diff --git a/spec/service/paged_documents_spec.rb b/spec/service/paged_documents_spec.rb index 87e7919..c6b2d40 100644 --- a/spec/service/paged_documents_spec.rb +++ b/spec/service/paged_documents_spec.rb @@ -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