Skip to content

Commit

Permalink
Moving to module to hijack Faraday errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cometman committed Sep 28, 2015
1 parent 96af63d commit 4661d10
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/open_calais/calais_error.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
class CalaisError < StandardError
attr_reader :object

def initialize(object)
@object = object
module Errors

This comment has been minimized.

Copy link
@knowtheory

knowtheory Oct 27, 2015

Member

Hey, so is there a reason why this is in a global Errors module rather than in say OpenCalais::Errors?

class RaiseError < Faraday::Response::Middleware

def on_complete(env)
raise Errors::NotFound if env[:status] == 404
end

end

end
end
10 changes: 10 additions & 0 deletions test/error_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + '/test_helper')

describe OpenCalais::Client do

it "is initialized with defaults" do
oc = OpenCalais::Client.new
oc.current_options.wont_be_nil
oc.current_options.must_equal OpenCalais.options
end
end

0 comments on commit 4661d10

Please sign in to comment.