Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added an exception manager

  • Loading branch information...
commit ff5cde7cb446f8b6e2681a603098bcd23910810e 1 parent 749043e
@bastien bastien authored
View
1  Gemfile
@@ -5,6 +5,7 @@ source "http://rubygems.org"
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
gem "activesupport", ">= 3.0.3"
+gem "i18n"
gem "multipart-post"
group :development do
View
2  Gemfile.lock
@@ -4,6 +4,7 @@ GEM
activesupport (3.0.3)
diff-lcs (1.1.2)
git (1.2.5)
+ i18n (0.6.0)
jeweler (1.5.2)
bundler (~> 1.0.0)
git (>= 1.2.5)
@@ -27,6 +28,7 @@ PLATFORMS
DEPENDENCIES
activesupport (>= 3.0.3)
bundler (~> 1.0.0)
+ i18n
jeweler (~> 1.5.2)
multipart-post
rcov
View
8 lib/issuu.rb
@@ -26,9 +26,5 @@ def configure
end
-require 'issuu/cli'
-require 'issuu/document'
-require 'issuu/bookmark'
-require 'issuu/folder'
-require 'issuu/parameter_set'
-require 'hash'
+Dir[File.dirname(__FILE__) +"/issuu/*.rb"].each {|file| require file }
+require File.dirname(__FILE__) + '/hash.rb'
View
2  lib/issuu/cli.rb
@@ -3,7 +3,7 @@ class Cli
class << self
def check_for_exceptions(json_data)
if json_data['rsp']['stat'].eql?("fail")
- raise(StandardError, json_data['rsp']["_content"]["error"]["message"])
+ IssuuExceptionManager.new(json_data['rsp']["_content"]["error"]).raise_error
end
end
View
18 lib/issuu/issuu_exception_manager.rb
@@ -0,0 +1,18 @@
+module Issuu
+ class IssuuExceptionManager
+ def initialize(params)
+ @message = "##{params["code"]} #{params["message"]}"
+ case params["code"]
+ when "200","201" then
+ @message << ": '#{params["field"]}'"
+ end
+ end
+
+ def raise_error
+ raise IssuuException, @message
+ end
+ end
+
+ class IssuuException < StandardError
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.