Hi Falood, I have created a param type for Time in my project like so:
defmodule Maru.ParamType.Time do
def from(string) do
Timex.parse!(string, "{ISO:Extended}")
end
end
If someone passes in an incorrectly formatted time, I'd like the request to fail with an error message. What's the best way to do this with maru? Should I raise an exception from within my from implementation?
Just raise an exception within from and rescue it by rescue_from.
By default, Maru.Exceptions.InvalidFormatter[reason: :illegal]will be raised if there's an ArgumentError
Hi Falood, I have created a param type for
Time
in my project like so:If someone passes in an incorrectly formatted time, I'd like the request to fail with an error message. What's the best way to do this with maru? Should I raise an exception from within my
from
implementation?Thanks!