class
Kemal::ParamError
- Kemal::ParamError
- Exception
- Reference
- Object
Overview
Exception raised when a parameter is missing from the request, or is present but its value cannot be converted to the declared type.
Example
@[Get("/users")]
def index(name : String, age : Int32)
"Hello, #{name}, age #{age}"
end
# GET /users?age=30 (no name=...) raises Kemal::ParamError for "name",
# reason: Missing
# GET /users?name=Ary&age=foo raises Kemal::ParamError for "age",
# reason: CastError
Defined in:
kemal/from_www_form.crConstructors
Instance Method Summary
-
#expected_type : String | Nil
The Crystal type name the parameter was declared as.
-
#param_name : String
The name of the parameter that failed.
-
#reason : Reason
Why the parameter failed.
-
#value : String | Nil
The raw, unparsed value that was posted for this parameter.
Constructor Detail
def self.new(param_name : String, reason : Kemal::ParamError::Reason, expected_type : Nil | String = nil, value : Nil | String = nil)
#
Instance Method Detail
def expected_type : String | Nil
#
The Crystal type name the parameter was declared as. nil when #reason is Missing.