Exception: Apique::MalformedParameters
- Inherits:
-
Exception
- Object
- Exception
- Apique::MalformedParameters
- Defined in:
- lib/apique/listable.rb
Overview
Exception will raise if a request query would contain an incorrect of malformed parameter. This will provide the front-end with a description of the correct API usage.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(request, param, params_usage, *args) ⇒ MalformedParameters
constructor
A new instance of MalformedParameters.
Constructor Details
#initialize(request, param, params_usage, *args) ⇒ MalformedParameters
Returns a new instance of MalformedParameters.
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/apique/listable.rb', line 36 def initialize(request, param, params_usage, *args) = "Bad request query: malformed parameter #{param}" usage = "GET #{request.fullpath[/[^?]+/]}?#{params_usage.keys*'&'}" @json = {message: , usage: usage, params: params_usage.values} = [ , "Usage: #{usage}", *params_usage.values.flat_map {|v| [v[:desc], "Example: #{v[:example]}"]} ]*"\n" super(, *args) end |
Instance Method Details
#as_json ⇒ Object
50 51 52 |
# File 'lib/apique/listable.rb', line 50 def as_json(*) @json end |