Is it possible to set a custom type name for a len...
# http4k
m
Is it possible to set a custom type name for a lens, to show up in the
LensFailure
? I tried this:
Copy code
Path.mapWithNewMeta(regex("([0-9a-fA-F])", 1), ParamMeta("Hex encoded")).of("myHexParam")
But it does not compile:
Copy code
Kotlin: Cannot access '<init>': it is protected in 'ParamMeta'
d
ah - maybe not then!
Also that is an illegal value for the param meta. You could only choose one of the other valid cases anyway because otherwise the spec would be broken
m
Without this, the error become:
Copy code
path 'myHexParam' must be string
which is not so helpful.
d
well, that's because it's piggybacking on the top of the entire lens system 🤷
m
You mean the OpenAPI spec? I am not using contracts now, only standard routes.
And
ServerFilters.CatchLensFailure
d
No. All of the lenses are piggybacking on the same infrastructure, which leads to the not-amazing-but-actually-unavoidable message 🙂
m
Another option would be to have the error message like this:
Copy code
path 'myHexParam' must be string with pattern '[0-9a-fA-F]'
d
yes, if we rewrote the entire system that would be possible,
j
Can values4k with validation help here?
d
not really. The problem isn't the validation - that works. it's documenting the path parameters in the openapi spec
j
OK, maybe I misunderstood, I thought it was about getting more info out of a LensFailureException.
m
It is about getting better error messages.