You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently there is no way to suppress refit exception from including request parameters like headers and query string which could include sensitive information that needs to be prevented from being dumped into the log.
Describe the solution you'd like
Add an additional property in RefitSettings.cs similar to ExceptionFactory that allows overriding refit's default exception during deserialization exception.
Describe alternatives you've considered
Wrapping all requests with try and catch and throwing custom exception works but it is a bit clunky and risky as it there is a possibility that someone might rethrow the exception or forget to wrap the request in try and catch completely.
Describe suggestions on how to achieve the feature
Add a property in RefitSettings.cs... public Func<HttpResponseMessage, Exception, Task<Exception?>>? DeserializationExceptionFactory { get; set; }
Use the factory in RequestBuilderImplementation.cs in BuildCancellableTaskFuncForMethod
Override both deserialization exceptions...
...
catch (Exception ex)
{
//if an error occured while attempting to deserialize return the wrapped ApiException
if (settings.DeserializationExceptionFactory != null)
e = await settings.DeserializationExceptionFactory(resp, ex).ConfigureAwait(false);
else
{
e = await ApiException.Create(
"An error occured deserializing the response.",
resp.RequestMessage!,
resp.RequestMessage!.Method,
resp,
settings,
ex
);
}
}
...
Is your feature request related to a problem? Please describe.
Currently there is no way to suppress refit exception from including request parameters like headers and query string which could include sensitive information that needs to be prevented from being dumped into the log.
Describe the solution you'd like
Add an additional property in RefitSettings.cs similar to ExceptionFactory that allows overriding refit's default exception during deserialization exception.
Describe alternatives you've considered
Wrapping all requests with try and catch and throwing custom exception works but it is a bit clunky and risky as it there is a possibility that someone might rethrow the exception or forget to wrap the request in try and catch completely.
Describe suggestions on how to achieve the feature
Add a property in RefitSettings.cs...
public Func<HttpResponseMessage, Exception, Task<Exception?>>? DeserializationExceptionFactory { get; set; }
Use the factory in RequestBuilderImplementation.cs in BuildCancellableTaskFuncForMethod
Override both deserialization exceptions...
Additional context
The text was updated successfully, but these errors were encountered: