Is your feature request related to a problem? Please describe.
When mapping from source with a nullable variable to a target with a corresponding non-nullable variable by tryConvert method, an exception is thrown. tryConvert should work in the same way as int.parse, so that each time there is any problem with parsing, a null is returned.
Describe the solution you'd like
Extend tryConvert method so that it catches all exceptions thrown during mapping (for example mapping a nullable variable to a non-nullable one). If any exception occurs, tryConvert returns null instead of throwing an exception. This behaviour is enabled by setting parameter safeMapping to true. By default safeMapping is false to keep backwards compatibility.
In addition, introduce optional parameter VoidCallback? onMappingError to tryConvert method that is called when exception during mapping occurs (can be used for example for logging).
Modify tryConvertList, convertIterable and convertSet accordingly.
Is your feature request related to a problem? Please describe. When mapping from source with a nullable variable to a target with a corresponding non-nullable variable by
tryConvert
method, an exception is thrown.tryConvert
should work in the same way asint.parse
, so that each time there is any problem with parsing, anull
is returned.Describe the solution you'd like Extend
tryConvert
method so that it catches all exceptions thrown during mapping (for example mapping a nullable variable to a non-nullable one). If any exception occurs,tryConvert
returnsnull
instead of throwing an exception. This behaviour is enabled by setting parametersafeMapping
totrue
. By defaultsafeMapping
is false to keep backwards compatibility.In addition, introduce optional parameter
VoidCallback? onMappingError
totryConvert
method that is called when exception during mapping occurs (can be used for example for logging).Modify
tryConvertList
,convertIterable
andconvertSet
accordingly.