File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -408,7 +408,7 @@ desc 'Returns your public timeline.' do
408408 description: ' Not really needed' ,
409409 required: false
410410 }
411-
411+
412412end
413413get :public_timeline do
414414 Status .limit(20 )
@@ -751,7 +751,9 @@ Aside from the default set of supported types listed above, any class can be
751751used as a type so long as an explicit coercion method is supplied. If the type
752752implements a class-level ` parse ` method, Grape will use it automatically.
753753This method must take one string argument and return an instance of the correct
754- type, or raise an exception to indicate the value was invalid. E.g.,
754+ type. An exception raised inside the ` parse ` method will be reported as a validation
755+ failure with a generic error message. To report a custom error message, return an
756+ ` InvalidValue ` initialized with the custom message. E.g.,
755757
756758``` ruby
757759class Color
@@ -761,8 +763,11 @@ class Color
761763 end
762764
763765 def self .parse (value )
764- fail ' Invalid color' unless %w(blue red green) .include?(value)
765- new (value)
766+ if %w(blue red green) .include?(value)
767+ new (value)
768+ else
769+ Grape ::Validations ::Types ::InvalidValue .new " is not a valid color"
770+ end
766771 end
767772end
768773
You can’t perform that action at this time.
0 commit comments