Sha256: be0f4a5657ceed45d40577d99104becc88653e2873593ad9e31517802de02b78

Contents?: true

Size: 438 Bytes

Versions: 7

Compression:

Stored size: 438 Bytes

Contents

module Mailstro
  module Middleware
    module Response
      class RaiseError < Faraday::Response::RaiseError
        def on_complete(env)
          case env[:status]
          when 401
            raise Error::AuthorisationError.new("api_key not authorised", env)
          when 422
            raise Error::ValidationError.new(env[:body][:errors])
          else
            super
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mailstro-0.0.10 lib/mailstro/middleware/response/raise_error.rb
mailstro-0.0.9 lib/mailstro/middleware/response/raise_error.rb
mailstro-0.0.8 lib/mailstro/middleware/response/raise_error.rb
mailstro-0.0.7 lib/mailstro/middleware/response/raise_error.rb
mailstro-0.0.6 lib/mailstro/middleware/response/raise_error.rb
mailstro-0.0.5 lib/mailstro/middleware/response/raise_error.rb
mailstro-0.0.4 lib/mailstro/middleware/response/raise_error.rb