Skip to content

Commit 975451f

Browse files
committed
display more validation errors on HTTP 422
references #269, #189
1 parent dc7441e commit 975451f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/hub/github_api.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ def error_sentences
130130
data['errors'].map do |err|
131131
case err['code']
132132
when 'custom' then err['message']
133-
when 'missing_field' then "field '%s' is missing" % err['field']
133+
when 'missing_field'
134+
%(Missing field: "%s") % err['field']
135+
when 'invalid'
136+
%(Invalid value for "%s": "%s") % [ err['field'], err['value'] ]
137+
when 'unauthorized'
138+
%(Not allowed to change field "%s") % err['field']
134139
end
135140
end.compact if data['errors']
136141
end

0 commit comments

Comments
 (0)