class Kemal::ParamError

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.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(param_name : String, reason : Kemal::ParamError::Reason, expected_type : Nil | String = nil, value : Nil | String = nil) #

[View source]

Instance Method Detail

def expected_type : String | Nil #

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


[View source]
def param_name : String #

The name of the parameter that failed.


[View source]
def reason : Reason #

Why the parameter failed.


[View source]
def value : String | Nil #

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


[View source]