-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update SdkException and subtypes (#166)
* feat: update SdkException and subtypes Adds errorCode and transportDetails properties. * Update SdkException constructor * fix property case Co-authored-by: Pete Gautier <[email protected]>
- Loading branch information
1 parent
5ff63f6
commit d757c1b
Showing
15 changed files
with
108 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,56 @@ | ||
using System; | ||
using Grpc.Core; | ||
|
||
namespace Momento.Sdk.Exceptions; | ||
|
||
public enum MomentoErrorCode { | ||
INVALID_ARGUMENT_ERROR, | ||
UNKNOWN_SERVICE_ERROR, | ||
ALREADY_EXISTS_ERROR, | ||
NOT_FOUND_ERROR, | ||
INTERNAL_SERVER_ERROR, | ||
PERMISSION_ERROR, | ||
AUTHENTICATION_ERROR, | ||
CANCELLED_ERROR, | ||
LIMIT_EXCEEDED_ERROR, | ||
BAD_REQUEST_ERROR, | ||
TIMEOUT_ERROR, | ||
SERVER_UNAVAILABLE, | ||
CLIENT_RESOURCE_EXHAUSTED, | ||
FAILED_PRECONDITION_ERROR, | ||
UNKNOWN_ERROR | ||
} | ||
|
||
public class MomentoGrpcErrorDetails { | ||
public StatusCode Code { get; } | ||
public string Details { get; } | ||
public Metadata? Metadata { get; } | ||
|
||
public MomentoGrpcErrorDetails(StatusCode code, string details, Metadata? metadata=null) | ||
{ | ||
this.Code = code; | ||
this.Details = details; | ||
this.Metadata = metadata; | ||
} | ||
|
||
} | ||
|
||
public class MomentoErrorTransportDetails { | ||
public MomentoGrpcErrorDetails Grpc { get; } | ||
|
||
public MomentoErrorTransportDetails(MomentoGrpcErrorDetails grpc) { | ||
this.Grpc = grpc; | ||
} | ||
} | ||
|
||
public abstract class SdkException : Exception | ||
{ | ||
protected SdkException(string message) : base(message) | ||
{ | ||
} | ||
protected SdkException(string message, Exception e) : base(message, e) | ||
public MomentoErrorCode ErrorCode { get; } | ||
public MomentoErrorTransportDetails? TransportDetails { get; } | ||
|
||
protected SdkException(MomentoErrorCode errorCode, string message, MomentoErrorTransportDetails? transportDetails=null, Exception? e=null) : base(message, e) | ||
{ | ||
this.ErrorCode = errorCode; | ||
this.TransportDetails = transportDetails; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters