forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.rb
More file actions
48 lines (41 loc) · 914 Bytes
/
error.rb
File metadata and controls
48 lines (41 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# encoding: utf-8
require 'github_api/descendants'
module Github
module Error
class GithubError < StandardError
extend Descendants
attr_reader :response_message, :response_headers
# Initialize a new Github error object.
#
def initialize(message=$!)
if message.respond_to?(:backtrace)
super(message.message)
@response_message = message
else
super(message.to_s)
end
end
def backtrace
@response_message ? @response_message.backtrace : super
end
end # GithubError
end # Error
end # Github
%w[
service_error
bad_request
unauthorized
forbidden
not_found
not_acceptable
unprocessable_entity
internal_server_error
service_unavailable
client_error
invalid_options
required_params
unknown_value
validations
].each do |error|
require "github_api/error/#{error}"
end