Skip to content

Commit

Permalink
feat: flatten exception hierarchy (#163)
Browse files Browse the repository at this point in the history
Co-authored-by: Pete Gautier <[email protected]>
  • Loading branch information
pgautier404 and pgautier404 authored Sep 20, 2022
1 parent 8ae8d47 commit ddfa8e1
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/Momento.Sdk/Exceptions/AlreadyExistsException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Resource already exists
/// </summary>
public class AlreadyExistsException : MomentoServiceException
public class AlreadyExistsException : SdkException
{
public AlreadyExistsException(string message) : base(message)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Momento.Sdk/Exceptions/AuthenticationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Authentication token is not provided or is invalid.
/// </summary>
public class AuthenticationException : MomentoServiceException
public class AuthenticationException : SdkException
{
public AuthenticationException(string message) : base(message)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Momento.Sdk/Exceptions/BadRequestException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Invalid parameters sent to Momento Services.
/// </summary>
public class BadRequestException : MomentoServiceException
public class BadRequestException : SdkException
{
public BadRequestException(string message) : base(message)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Momento.Sdk/Exceptions/CacheExceptionMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ public static Exception Convert(Exception e)
default: return new InternalServerException(INTERNAL_SERVER_ERROR_MESSAGE, e);
}
}
return new ClientSdkException(SDK_ERROR_MESSAGE, e);
return new UnknownException(SDK_ERROR_MESSAGE, e);
}
}
2 changes: 1 addition & 1 deletion src/Momento.Sdk/Exceptions/CancelledException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Momento.Sdk.Exceptions;

public class CancelledException : MomentoServiceException
public class CancelledException : SdkException
{
/// <summary>
/// Operation was cancelled.
Expand Down
13 changes: 0 additions & 13 deletions src/Momento.Sdk/Exceptions/ClientSdkException.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Momento.Sdk/Exceptions/FailedPreconditionException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Momento.Sdk.Exceptions;
/// For example, calling <c>Increment</c> on a key that doesn't store
/// a number.
/// </summary>
public class FailedPreconditionException : MomentoServiceException
public class FailedPreconditionException : SdkException
{
public FailedPreconditionException(string message) : base(message)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Momento.Sdk/Exceptions/InternalServerException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Momento.Sdk.Exceptions;
/// <summary>
/// Momento Service encountered an unexpected exception while trying to fulfill the request.
/// </summary>
public class InternalServerException : MomentoServiceException
public class InternalServerException : SdkException
{
public InternalServerException(string message, Exception e) : base(message, e)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Momento.Sdk/Exceptions/InvalidArgumentException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Momento.Sdk.Exceptions;
/// <summary>
/// SDK client side validation failed.
/// </summary>
public class InvalidArgumentException : ClientSdkException
public class InvalidArgumentException : SdkException
{
public InvalidArgumentException(string message) : base(message)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Momento.Sdk/Exceptions/LimitExceededException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Requested operation couldn't be completed because system limits were hit.
/// </summary>
public class LimitExceededException : MomentoServiceException
public class LimitExceededException : SdkException
{
public LimitExceededException(string message) : base(message)
{
Expand Down
16 changes: 0 additions & 16 deletions src/Momento.Sdk/Exceptions/MomentoServiceException.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Momento.Sdk/Exceptions/NotFoundException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Requested resource or the resource on which an operation was requested doesn't exist.
/// </summary>
public class NotFoundException : MomentoServiceException
public class NotFoundException : SdkException
{
public NotFoundException(string message) : base(message)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Momento.Sdk/Exceptions/PermissionDeniedException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Insufficient permissions to execute an operation.
/// </summary>
public class PermissionDeniedException : MomentoServiceException
public class PermissionDeniedException : SdkException
{
public PermissionDeniedException(string message) : base(message)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Momento.Sdk/Exceptions/TimeoutException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Requested operation did not complete in allotted time.
/// </summary>
public class TimeoutException : MomentoServiceException
public class TimeoutException : SdkException
{
public TimeoutException(string message) : base(message)
{
Expand Down
16 changes: 16 additions & 0 deletions src/Momento.Sdk/Exceptions/UnknownException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Momento.Sdk.Exceptions;

using System;

/// <summary>
/// Unhandled exception from CacheExceptionMapper
/// </summary>
public class UnknownException : SdkException
{
public UnknownException(string message) : base(message)
{
}
public UnknownException(string message, Exception e) : base(message, e)
{
}
}

0 comments on commit ddfa8e1

Please sign in to comment.