@@ -19,5 +19,69 @@ def generate_message(attributes)
1919 "\n Resolution:\n #{ @resolution } "
2020 end
2121 end
22+
23+ # Raised when invalid options are passed to a request body
24+ class InvalidOptions < ClientError
25+ def initialize ( invalid , valid )
26+ super (
27+ generate_message (
28+ problem : "Invalid option #{ invalid . keys . join ( ', ' ) } provided for this request." ,
29+ summary : "Github gem checks the request parameters passed to ensure that github api is not hit unnecessairly and to fail fast." ,
30+ resolution : "Valid options are: #{ valid . join ( ', ' ) } , make sure these are the ones you are using"
31+ )
32+ )
33+ end
34+ end
35+
36+ # Raised when invalid options are passed to a request body
37+ class RequiredParams < ClientError
38+ def initialize ( provided , required )
39+ super (
40+ generate_message (
41+ problem : "Missing required parameters: #{ provided . keys . join ( ', ' ) } provided for this request." ,
42+ summary : "Github gem checks the request parameters passed to ensure that github api is not hit unnecessairly and to fail fast." ,
43+ resolution : "Required parameters are: #{ required . join ( ', ' ) } , make sure these are the ones you are using"
44+ )
45+ )
46+ end
47+ end
48+
49+ # Raised when invalid options are passed to a request body
50+ class UnknownMedia < ClientError
51+ def initialize ( file )
52+ super (
53+ generate_message (
54+ problem : "Unknown content type for: '#{ file } ' provided for this request." ,
55+ summary : "Github gem infers the content type of the resource by calling the mime-types gem type inference." ,
56+ resolution : "Please install mime-types gem to infer the resource content type."
57+ )
58+ )
59+ end
60+ end
61+
62+ # Raised when invalid options are passed to a request body
63+ class UnknownValue < ClientError
64+ def initialize ( key , value , permitted )
65+ super (
66+ generate_message (
67+ problem : "Wrong value of '#{ value } ' for the parameter: #{ key } provided for this request." ,
68+ summary : "Github gem checks the request parameters passed to ensure that github api is not hit unnecessairly and fails fast." ,
69+ resolution : "Permitted values are: #{ permitted } , make sure these are the ones you are using"
70+ )
71+ )
72+ end
73+ end
74+
75+ class Validations < ClientError
76+ def initialize ( errors )
77+ super (
78+ generate_message (
79+ problem : "Attempted to send request with nil arguments for #{ errors . keys . join ( ', ' ) } ." ,
80+ summary : 'Each request expects certain number of required arguments.' ,
81+ resolution : 'Double check that the provided arguments are set to some value that is neither nil nor empty string.'
82+ )
83+ )
84+ end
85+ end
2286 end # Error
2387end # Github
0 commit comments