Browse Source

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

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

* remove whitespace
pull/1773/head
Jake Fink 4 years ago committed by GitHub
parent
commit
11aafac915
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/Admin/HostedServices/DatabaseMigrationHostedService.cs
  2. 4
      src/Billing/Controllers/StripeController.cs
  3. 7
      src/Core/Repositories/TableStorage/InstallationDeviceRepository.cs
  4. 7
      src/Core/Repositories/TableStorage/MetaDataRepository.cs
  5. 2
      src/Core/Services/Implementations/AmazonSesMailDeliveryService.cs
  6. 14
      src/Core/Services/Implementations/NotificationHubPushRegistrationService.cs
  7. 12
      src/Core/Services/Implementations/StripePaymentService.cs
  8. 2
      util/Setup/Program.cs

2
src/Admin/HostedServices/DatabaseMigrationHostedService.cs

@ -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
{ {

4
src/Billing/Controllers/StripeController.cs

@ -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;
} }
} }

7
src/Core/Repositories/TableStorage/InstallationDeviceRepository.cs

@ -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;
}
} }
} }
} }

7
src/Core/Repositories/TableStorage/MetaDataRepository.cs

@ -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;
}
} }
} }
} }

2
src/Core/Services/Implementations/AmazonSesMailDeliveryService.cs

@ -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;
} }
} }

14
src/Core/Services/Implementations/NotificationHubPushRegistrationService.cs

@ -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;
}
} }
} }
} }

12
src/Core/Services/Implementations/StripePaymentService.cs

@ -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;

2
util/Setup/Program.cs

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

Loading…
Cancel
Save