File tree 2 files changed +18
-3
lines changed
Filter options
2 files changed +18
-3
lines changed
Original file line number Diff line number Diff line change @@ -68,8 +68,14 @@ def initialize(msg: 'A Qiita item ID is invalid.')
68
68
end
69
69
70
70
class QiitaAPIError < StandardError
71
- def initialize ( msg : 'A Qiita API returns a non-succeeded status.' , response : nil )
72
- msg += " Status code: #{ response . status } , Response body: #{ JSON . parse ( response . body ) } " unless response . nil?
71
+ def initialize ( msg : 'A Qiita API returns a non-succeeded status.' , data : nil )
72
+ unless data . nil?
73
+ msg += " Status code: #{ data [ :response ] . status } ," \
74
+ " Response body: #{ JSON . parse ( data [ :response ] . body ) } ," \
75
+ " Header: #{ data [ :header ] } ," \
76
+ " Mode: \" #{ data [ :mode ] } \" , Path: \" #{ data [ :path ] } \" "
77
+ end
78
+
73
79
super ( msg )
74
80
end
75
81
end
Original file line number Diff line number Diff line change @@ -37,7 +37,16 @@ def publish
37
37
connection . patch ( &request_params )
38
38
end
39
39
40
- raise QiitaAPIError . new ( response : response ) unless response . status >= 200 && response . status < 300
40
+ unless response . status >= 200 && response . status < 300
41
+ raise QiitaAPIError . new (
42
+ data : {
43
+ response : response ,
44
+ header : @header ,
45
+ mode : @mode ,
46
+ path : @path
47
+ }
48
+ )
49
+ end
41
50
42
51
JSON . parse ( response . body )
43
52
end
You can’t perform that action at this time.
0 commit comments