class

Kemal::ParamError

Inherits Exception < Reference < Object

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

Constructors

new(param_name : String, reason : Kemal::ParamError::Reason, expected_type : Nil | String = nil, value : Nil | String = nil)
Source

Instance methods

expected_type

The Crystal type name the parameter was declared as. nil when reason is Missing.

Source
param_name

The name of the parameter that failed.

Source
reason

Why the parameter failed.

Source
value

The raw, unparsed value that was posted for this parameter. nil when reason is Missing.

Source

Nested types