public void ConfigureServices(IServiceCollection services) { services .AddProblemDetails(setup => { setup.IncludeExceptionDetails = _ => !Environment.IsDevelopment(); setup.Map<OutOfCreditException>(exception => new OutOfCreditProblemDetails { Title = exception.Message, Detail = exception.Description, Balance = exception.Balance, Status = StatusCodes.Status403Forbidden, Type = exception.Type }); }) ... }