Skip to content

Commit

Permalink
adding error classes for better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sfaxon committed Aug 22, 2011
1 parent 5ad94c2 commit 6248963
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/remote_book/amazon.rb
@@ -1,4 +1,7 @@
module RemoteBook
class AmazonError < RemoteBook::RemoteBookError #:nodoc:
end

class Amazon < RemoteBook::Base
# FIXME: failed digest support should raise exception.
# mac os 10.5 does not ship with SHA256 support built into ruby, 10.6 does.
Expand All @@ -8,6 +11,9 @@ class Amazon < RemoteBook::Base
attr_accessor :large_image, :medium_image, :small_image, :authors, :title

def self.find(options)
raise AmazonError.new("RemoteBook::Amazon.associate_keys requires :key_id") unless associate_keys.has_key?(:key_id)
raise AmazonError.new("RemoteBook::Amazon.associate_keys requires :associates_id") unless associate_keys.has_key?(:associates_id)
raise AmazonError.new("RemoteBook::Amazon.associate_keys requires :secret_key") unless associate_keys.has_key?(:secret_key)
a = new
# unless DIGEST_SUPPORT raise "no digest sup"
if options[:isbn]
Expand Down
3 changes: 3 additions & 0 deletions lib/remote_book/barnes_and_noble.rb
@@ -1,4 +1,7 @@
module RemoteBook
class BarnesAndNobleError < RemoteBook::RemoteBookError #:nodoc:
end

class BarnesAndNoble < RemoteBook::Base
ISBN_SEARCH_BASE_URI = "http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?ISBSRC=Y&ISBN="
LINK_SHARE_DEEP_LINK_BASE = "http://getdeeplink.linksynergy.com/createcustomlink.shtml"
Expand Down
2 changes: 2 additions & 0 deletions lib/remote_book/base.rb
Expand Up @@ -28,4 +28,6 @@ def find(options)
end
end
end
class RemoteBookError < StandardError #:nodoc:
end
end

0 comments on commit 6248963

Please sign in to comment.