-
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
Adds errorCode and transportDetails properties.
- Loading branch information
1 parent
ddfa8e1
commit 16af95d
Showing
15 changed files
with
115 additions
and
28 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,65 @@ | ||
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; | ||
public string details; | ||
public Metadata? metadata = null; | ||
|
||
public MomentoGrpcErrorDetails(StatusCode code, string details, Metadata? metadata) | ||
{ | ||
this.code = code; | ||
this.details = details; | ||
this.metadata = metadata; | ||
} | ||
|
||
} | ||
|
||
public class MomentoErrorTransportDetails { | ||
public MomentoGrpcErrorDetails grpc; | ||
|
||
public MomentoErrorTransportDetails(MomentoGrpcErrorDetails grpc) { | ||
this.grpc = grpc; | ||
} | ||
} | ||
|
||
public abstract class SdkException : Exception | ||
{ | ||
protected SdkException(string message) : base(message) | ||
public MomentoErrorCode errorCode; | ||
public MomentoErrorTransportDetails? transportDetails = null; | ||
|
||
protected SdkException(string message, MomentoErrorCode errorCode) : base(message) | ||
{ | ||
this.errorCode = errorCode; | ||
} | ||
protected SdkException(string message, MomentoErrorCode errorCode, MomentoErrorTransportDetails transportDetails) : base(message) | ||
{ | ||
this.errorCode = errorCode; | ||
this.transportDetails = transportDetails; | ||
} | ||
protected SdkException(string message, Exception e) : base(message, e) | ||
protected SdkException(string message, MomentoErrorCode errorCode, MomentoErrorTransportDetails? transportDetails, Exception e) : 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