1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-20 19:14:32 -05:00

remove re-throws of exceptions, which clear the stack trace (#1760)

* remove re-throws of exceptions, which clear the stack trace

* remove whitespace
This commit is contained in:
Jake Fink 2021-12-16 15:35:07 -05:00 committed by GitHub
parent 44b993ed38
commit 11aafac915
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 19 additions and 31 deletions

View File

@ -46,7 +46,7 @@ namespace Bit.Admin.HostedServices
if (i >= maxMigrationAttempts) if (i >= maxMigrationAttempts)
{ {
_logger.LogError(e, "Database failed to migrate."); _logger.LogError(e, "Database failed to migrate.");
throw e; throw;
} }
else else
{ {

View File

@ -603,7 +603,7 @@ namespace Bit.Billing.Controllers
} }
else else
{ {
throw e; throw;
} }
} }
@ -698,7 +698,7 @@ namespace Bit.Billing.Controllers
} }
else else
{ {
throw e; throw;
} }
} }

View File

@ -79,12 +79,9 @@ namespace Bit.Core.Repositories.TableStorage
entity.ETag = "*"; entity.ETag = "*";
await _table.ExecuteAsync(TableOperation.Delete(entity)); await _table.ExecuteAsync(TableOperation.Delete(entity));
} }
catch (StorageException e) catch (StorageException e) when (e.RequestInformation.HttpStatusCode != (int)HttpStatusCode.NotFound)
{ {
if (e.RequestInformation.HttpStatusCode != (int)HttpStatusCode.NotFound) throw;
{
throw e;
}
} }
} }
} }

View File

@ -88,12 +88,9 @@ namespace Bit.Core.Repositories.TableStorage
ETag = "*" ETag = "*"
})); }));
} }
catch (StorageException e) catch (StorageException e) when (e.RequestInformation.HttpStatusCode != (int)HttpStatusCode.NotFound)
{ {
if (e.RequestInformation.HttpStatusCode != (int)HttpStatusCode.NotFound) throw;
{
throw e;
}
} }
} }
} }

View File

@ -130,7 +130,7 @@ namespace Bit.Core.Services
{ {
_logger.LogWarning(e, "Failed to send email. Retrying..."); _logger.LogWarning(e, "Failed to send email. Retrying...");
await SendAsync(request, true); await SendAsync(request, true);
throw e; throw;
} }
} }

View File

@ -133,12 +133,9 @@ namespace Bit.Core.Services
await _installationDeviceRepository.DeleteAsync(new InstallationDeviceEntity(deviceId)); await _installationDeviceRepository.DeleteAsync(new InstallationDeviceEntity(deviceId));
} }
} }
catch (Exception e) catch (Exception e) when (e.InnerException == null || !e.InnerException.Message.Contains("(404) Not Found"))
{ {
if (e.InnerException == null || !e.InnerException.Message.Contains("(404) Not Found")) throw;
{
throw e;
}
} }
} }
@ -192,12 +189,9 @@ namespace Bit.Core.Services
{ {
await _client.PatchInstallationAsync(id, new List<PartialUpdateOperation> { operation }); await _client.PatchInstallationAsync(id, new List<PartialUpdateOperation> { operation });
} }
catch (Exception e) catch (Exception e) when (e.InnerException == null || !e.InnerException.Message.Contains("(404) Not Found"))
{ {
if (e.InnerException == null || !e.InnerException.Message.Contains("(404) Not Found")) throw;
{
throw e;
}
} }
} }
} }

View File

@ -171,7 +171,7 @@ namespace Bit.Core.Services
{ {
await _btGateway.Customer.DeleteAsync(braintreeCustomer.Id); await _btGateway.Customer.DeleteAsync(braintreeCustomer.Id);
} }
throw e; throw;
} }
org.Gateway = GatewayType.Stripe; org.Gateway = GatewayType.Stripe;
@ -367,7 +367,7 @@ namespace Bit.Core.Services
var message = e.Message.ToLowerInvariant(); var message = e.Message.ToLowerInvariant();
if (message.Contains("apple") || message.Contains("in-app")) if (message.Contains("apple") || message.Contains("in-app"))
{ {
throw e; throw;
} }
} }
} }
@ -692,7 +692,7 @@ namespace Bit.Core.Services
throw new GatewayException("Bank account is not yet verified."); throw new GatewayException("Bank account is not yet verified.");
} }
throw e; throw;
} }
} }
@ -1105,7 +1105,7 @@ namespace Bit.Core.Services
{ {
if (e.Message != $"No such subscription: {subscriber.GatewaySubscriptionId}") if (e.Message != $"No such subscription: {subscriber.GatewaySubscriptionId}")
{ {
throw e; throw;
} }
} }
} }
@ -1408,13 +1408,13 @@ namespace Bit.Core.Services
}); });
} }
} }
catch (Exception e) catch
{ {
if (braintreeCustomer != null && !hadBtCustomer) if (braintreeCustomer != null && !hadBtCustomer)
{ {
await _btGateway.Customer.DeleteAsync(braintreeCustomer.Id); await _btGateway.Customer.DeleteAsync(braintreeCustomer.Id);
} }
throw e; throw;
} }
return createdCustomer; return createdCustomer;

View File

@ -213,7 +213,7 @@ namespace Bit.Setup
MigrateDatabase(nextAttempt); MigrateDatabase(nextAttempt);
return; return;
} }
throw e; throw;
} }
} }