runCatching
Executes the given block and captures its result or exception within an EncodableResult. If the block executes successfully, its result is encapsulated as a success. If the block throws an exception, the exception is wrapped and encapsulated as a failure.
Return
An EncodableResult instance representing either a success or a failure, along with the provided or default metadata.
Parameters
metadata
Optional metadata to be associated with the result.
block
The lambda to be executed that provides the result.