From c698107f505d757e62a5b51a8c8f2fdebf5115e9 Mon Sep 17 00:00:00 2001 From: Michael Landis Date: Mon, 1 May 2023 18:09:06 -0700 Subject: [PATCH] chore: add interface for all error response types (#434) In the current formulation, downstream code cannot consume a generic Error type, because current error types inherit from a parent abstract class. This PR introduces an error interface, IError, which specifies that an error response has the following properties: InnerException ErrorCode Message which is common to all error classes. With this in place we inherit the documentation from the interface, simplifying the doc strings in the response classes. Eventually we should the same for Success, Hit, and Miss. --- .../Responses/CacheDeleteResponse.cs | 8 ++--- .../Responses/CacheDictionaryFetchResponse.cs | 8 ++--- .../CacheDictionaryGetFieldResponse.cs | 8 ++--- .../CacheDictionaryGetFieldsResponse.cs | 8 ++--- .../CacheDictionaryIncrementResponse.cs | 8 ++--- .../CacheDictionaryRemoveFieldResponse.cs | 8 ++--- .../CacheDictionaryRemoveFieldsResponse.cs | 8 ++--- .../CacheDictionarySetFieldResponse.cs | 8 ++--- .../CacheDictionarySetFieldsResponse.cs | 8 ++--- .../Responses/CacheGetBatchResponse.cs | 2 +- src/Momento.Sdk/Responses/CacheGetResponse.cs | 8 ++--- .../Responses/CacheIncrementResponse.cs | 8 ++--- .../Responses/CacheKeyExistsResponse.cs | 8 ++--- .../Responses/CacheKeysExistResponse.cs | 8 ++--- .../CacheListConcatenateBackResponse.cs | 8 ++--- .../CacheListConcatenateFrontResponse.cs | 8 ++--- .../Responses/CacheListFetchResponse.cs | 8 ++--- .../Responses/CacheListLengthResponse.cs | 8 ++--- .../Responses/CacheListPopBackResponse.cs | 8 ++--- .../Responses/CacheListPopFrontResponse.cs | 8 ++--- .../Responses/CacheListPushBackResponse.cs | 8 ++--- .../Responses/CacheListPushFrontResponse.cs | 8 ++--- .../Responses/CacheListRemoveValueResponse.cs | 8 ++--- .../Responses/CacheListRetainResponse.cs | 8 ++--- .../Responses/CacheSetAddElementResponse.cs | 8 ++--- .../Responses/CacheSetAddElementsResponse.cs | 8 ++--- .../Responses/CacheSetBatchResponse.cs | 2 +- .../Responses/CacheSetFetchResponse.cs | 8 ++--- .../Responses/CacheSetIfNotExistsResponse.cs | 8 ++--- .../CacheSetRemoveElementResponse.cs | 8 ++--- .../CacheSetRemoveElementsResponse.cs | 8 ++--- src/Momento.Sdk/Responses/CacheSetResponse.cs | 8 ++--- .../Responses/CreateCacheResponse.cs | 8 ++--- .../Responses/DeleteCacheResponse.cs | 8 ++--- .../Responses/FlushCacheResponse.cs | 8 ++--- src/Momento.Sdk/Responses/IError.cs | 33 +++++++++++++++++++ .../Responses/ListCachesResponse.cs | 8 ++--- src/Momento.Sdk/docs.xml | 23 ------------- 38 files changed, 171 insertions(+), 161 deletions(-) create mode 100644 src/Momento.Sdk/Responses/IError.cs diff --git a/src/Momento.Sdk/Responses/CacheDeleteResponse.cs b/src/Momento.Sdk/Responses/CacheDeleteResponse.cs index 9a3837dd..814951a7 100644 --- a/src/Momento.Sdk/Responses/CacheDeleteResponse.cs +++ b/src/Momento.Sdk/Responses/CacheDeleteResponse.cs @@ -33,7 +33,7 @@ public abstract class CacheDeleteResponse public class Success : CacheDeleteResponse { } /// - public class Error : CacheDeleteResponse + public class Error : CacheDeleteResponse, IError { private readonly SdkException _error; @@ -43,19 +43,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheDictionaryFetchResponse.cs b/src/Momento.Sdk/Responses/CacheDictionaryFetchResponse.cs index 5cc498a3..1d8494e4 100644 --- a/src/Momento.Sdk/Responses/CacheDictionaryFetchResponse.cs +++ b/src/Momento.Sdk/Responses/CacheDictionaryFetchResponse.cs @@ -111,7 +111,7 @@ public class Miss : CacheDictionaryFetchResponse } /// - public class Error : CacheDictionaryFetchResponse + public class Error : CacheDictionaryFetchResponse, IError { private readonly SdkException _error; @@ -121,19 +121,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheDictionaryGetFieldResponse.cs b/src/Momento.Sdk/Responses/CacheDictionaryGetFieldResponse.cs index 74fea5d0..3e80e19b 100644 --- a/src/Momento.Sdk/Responses/CacheDictionaryGetFieldResponse.cs +++ b/src/Momento.Sdk/Responses/CacheDictionaryGetFieldResponse.cs @@ -123,7 +123,7 @@ public Miss(ByteString field) : base(field) } /// - public class Error : CacheDictionaryGetFieldResponse + public class Error : CacheDictionaryGetFieldResponse, IError { private readonly SdkException _error; @@ -139,19 +139,19 @@ public Error(ByteString field, SdkException error) : base(field) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheDictionaryGetFieldsResponse.cs b/src/Momento.Sdk/Responses/CacheDictionaryGetFieldsResponse.cs index c9f2fdd2..7ebdcd09 100644 --- a/src/Momento.Sdk/Responses/CacheDictionaryGetFieldsResponse.cs +++ b/src/Momento.Sdk/Responses/CacheDictionaryGetFieldsResponse.cs @@ -146,7 +146,7 @@ public class Miss : CacheDictionaryGetFieldsResponse } /// - public class Error : CacheDictionaryGetFieldsResponse + public class Error : CacheDictionaryGetFieldsResponse, IError { private readonly SdkException _error; @@ -156,19 +156,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheDictionaryIncrementResponse.cs b/src/Momento.Sdk/Responses/CacheDictionaryIncrementResponse.cs index 30b1c747..a5061327 100644 --- a/src/Momento.Sdk/Responses/CacheDictionaryIncrementResponse.cs +++ b/src/Momento.Sdk/Responses/CacheDictionaryIncrementResponse.cs @@ -52,7 +52,7 @@ public override string ToString() } /// - public class Error : CacheDictionaryIncrementResponse + public class Error : CacheDictionaryIncrementResponse, IError { private readonly SdkException _error; @@ -62,19 +62,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheDictionaryRemoveFieldResponse.cs b/src/Momento.Sdk/Responses/CacheDictionaryRemoveFieldResponse.cs index 2c9c4e92..7c1722a0 100644 --- a/src/Momento.Sdk/Responses/CacheDictionaryRemoveFieldResponse.cs +++ b/src/Momento.Sdk/Responses/CacheDictionaryRemoveFieldResponse.cs @@ -35,7 +35,7 @@ public class Success : CacheDictionaryRemoveFieldResponse } /// - public class Error : CacheDictionaryRemoveFieldResponse + public class Error : CacheDictionaryRemoveFieldResponse, IError { private readonly SdkException _error; @@ -45,19 +45,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheDictionaryRemoveFieldsResponse.cs b/src/Momento.Sdk/Responses/CacheDictionaryRemoveFieldsResponse.cs index 36458a45..bebd6a86 100644 --- a/src/Momento.Sdk/Responses/CacheDictionaryRemoveFieldsResponse.cs +++ b/src/Momento.Sdk/Responses/CacheDictionaryRemoveFieldsResponse.cs @@ -35,7 +35,7 @@ public class Success : CacheDictionaryRemoveFieldsResponse } /// - public class Error : CacheDictionaryRemoveFieldsResponse + public class Error : CacheDictionaryRemoveFieldsResponse, IError { private readonly SdkException _error; @@ -45,19 +45,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheDictionarySetFieldResponse.cs b/src/Momento.Sdk/Responses/CacheDictionarySetFieldResponse.cs index 1e5e19b2..96224def 100644 --- a/src/Momento.Sdk/Responses/CacheDictionarySetFieldResponse.cs +++ b/src/Momento.Sdk/Responses/CacheDictionarySetFieldResponse.cs @@ -35,7 +35,7 @@ public class Success : CacheDictionarySetFieldResponse } /// - public class Error : CacheDictionarySetFieldResponse + public class Error : CacheDictionarySetFieldResponse, IError { private readonly SdkException _error; @@ -45,19 +45,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheDictionarySetFieldsResponse.cs b/src/Momento.Sdk/Responses/CacheDictionarySetFieldsResponse.cs index 1d22800b..788486bb 100644 --- a/src/Momento.Sdk/Responses/CacheDictionarySetFieldsResponse.cs +++ b/src/Momento.Sdk/Responses/CacheDictionarySetFieldsResponse.cs @@ -35,7 +35,7 @@ public class Success : CacheDictionarySetFieldsResponse } /// - public class Error : CacheDictionarySetFieldsResponse + public class Error : CacheDictionarySetFieldsResponse, IError { private readonly SdkException _error; @@ -45,19 +45,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs b/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs index 6ad94b55..565d8495 100644 --- a/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs +++ b/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs @@ -58,7 +58,7 @@ public IEnumerable ValueByteArrays } } - public class Error : CacheGetBatchResponse + public class Error : CacheGetBatchResponse, IError { private readonly SdkException _error; public Error(SdkException error) diff --git a/src/Momento.Sdk/Responses/CacheGetResponse.cs b/src/Momento.Sdk/Responses/CacheGetResponse.cs index a6a9556b..82866f0b 100644 --- a/src/Momento.Sdk/Responses/CacheGetResponse.cs +++ b/src/Momento.Sdk/Responses/CacheGetResponse.cs @@ -85,7 +85,7 @@ public class Miss : CacheGetResponse } /// - public class Error : CacheGetResponse + public class Error : CacheGetResponse, IError { private readonly SdkException _error; @@ -95,19 +95,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheIncrementResponse.cs b/src/Momento.Sdk/Responses/CacheIncrementResponse.cs index b646b6a9..00fe4946 100644 --- a/src/Momento.Sdk/Responses/CacheIncrementResponse.cs +++ b/src/Momento.Sdk/Responses/CacheIncrementResponse.cs @@ -52,7 +52,7 @@ public override string ToString() } /// - public class Error : CacheIncrementResponse + public class Error : CacheIncrementResponse, IError { private readonly SdkException _error; @@ -62,19 +62,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheKeyExistsResponse.cs b/src/Momento.Sdk/Responses/CacheKeyExistsResponse.cs index 340fa905..05021655 100644 --- a/src/Momento.Sdk/Responses/CacheKeyExistsResponse.cs +++ b/src/Momento.Sdk/Responses/CacheKeyExistsResponse.cs @@ -53,7 +53,7 @@ public override string ToString() } /// - public class Error : CacheKeyExistsResponse + public class Error : CacheKeyExistsResponse, IError { private readonly SdkException _error; @@ -63,19 +63,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheKeysExistResponse.cs b/src/Momento.Sdk/Responses/CacheKeysExistResponse.cs index 748dfbdf..119435ba 100644 --- a/src/Momento.Sdk/Responses/CacheKeysExistResponse.cs +++ b/src/Momento.Sdk/Responses/CacheKeysExistResponse.cs @@ -82,7 +82,7 @@ public override string ToString() } /// - public class Error : CacheKeysExistResponse + public class Error : CacheKeysExistResponse, IError { private readonly SdkException _error; @@ -92,19 +92,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheListConcatenateBackResponse.cs b/src/Momento.Sdk/Responses/CacheListConcatenateBackResponse.cs index fbd38455..de277126 100644 --- a/src/Momento.Sdk/Responses/CacheListConcatenateBackResponse.cs +++ b/src/Momento.Sdk/Responses/CacheListConcatenateBackResponse.cs @@ -55,7 +55,7 @@ public override string ToString() } /// - public class Error : CacheListConcatenateBackResponse + public class Error : CacheListConcatenateBackResponse, IError { private readonly SdkException _error; @@ -65,19 +65,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheListConcatenateFrontResponse.cs b/src/Momento.Sdk/Responses/CacheListConcatenateFrontResponse.cs index 6628497b..4ab870a9 100644 --- a/src/Momento.Sdk/Responses/CacheListConcatenateFrontResponse.cs +++ b/src/Momento.Sdk/Responses/CacheListConcatenateFrontResponse.cs @@ -55,7 +55,7 @@ public override string ToString() } /// - public class Error : CacheListConcatenateFrontResponse + public class Error : CacheListConcatenateFrontResponse, IError { private readonly SdkException _error; @@ -65,19 +65,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheListFetchResponse.cs b/src/Momento.Sdk/Responses/CacheListFetchResponse.cs index 26b49d2c..a7699485 100644 --- a/src/Momento.Sdk/Responses/CacheListFetchResponse.cs +++ b/src/Momento.Sdk/Responses/CacheListFetchResponse.cs @@ -94,7 +94,7 @@ public class Miss : CacheListFetchResponse } /// - public class Error : CacheListFetchResponse + public class Error : CacheListFetchResponse, IError { private readonly SdkException _error; @@ -104,19 +104,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheListLengthResponse.cs b/src/Momento.Sdk/Responses/CacheListLengthResponse.cs index 390aa3c4..f73e3409 100644 --- a/src/Momento.Sdk/Responses/CacheListLengthResponse.cs +++ b/src/Momento.Sdk/Responses/CacheListLengthResponse.cs @@ -58,7 +58,7 @@ public override string ToString() } /// - public class Error : CacheListLengthResponse + public class Error : CacheListLengthResponse, IError { private readonly SdkException _error; @@ -68,19 +68,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheListPopBackResponse.cs b/src/Momento.Sdk/Responses/CacheListPopBackResponse.cs index ef8ae1e0..8f385aa7 100644 --- a/src/Momento.Sdk/Responses/CacheListPopBackResponse.cs +++ b/src/Momento.Sdk/Responses/CacheListPopBackResponse.cs @@ -80,7 +80,7 @@ public class Miss : CacheListPopBackResponse } /// - public class Error : CacheListPopBackResponse + public class Error : CacheListPopBackResponse, IError { private readonly SdkException _error; @@ -90,19 +90,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheListPopFrontResponse.cs b/src/Momento.Sdk/Responses/CacheListPopFrontResponse.cs index 1bbfcce1..ec74aefd 100644 --- a/src/Momento.Sdk/Responses/CacheListPopFrontResponse.cs +++ b/src/Momento.Sdk/Responses/CacheListPopFrontResponse.cs @@ -80,7 +80,7 @@ public class Miss : CacheListPopFrontResponse } /// - public class Error : CacheListPopFrontResponse + public class Error : CacheListPopFrontResponse, IError { private readonly SdkException _error; @@ -90,19 +90,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheListPushBackResponse.cs b/src/Momento.Sdk/Responses/CacheListPushBackResponse.cs index 9a3a0151..03f9b809 100644 --- a/src/Momento.Sdk/Responses/CacheListPushBackResponse.cs +++ b/src/Momento.Sdk/Responses/CacheListPushBackResponse.cs @@ -56,7 +56,7 @@ public override string ToString() } /// - public class Error : CacheListPushBackResponse + public class Error : CacheListPushBackResponse, IError { private readonly SdkException _error; @@ -66,19 +66,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheListPushFrontResponse.cs b/src/Momento.Sdk/Responses/CacheListPushFrontResponse.cs index b3435837..a11ff61d 100644 --- a/src/Momento.Sdk/Responses/CacheListPushFrontResponse.cs +++ b/src/Momento.Sdk/Responses/CacheListPushFrontResponse.cs @@ -55,7 +55,7 @@ public override string ToString() } /// - public class Error : CacheListPushFrontResponse + public class Error : CacheListPushFrontResponse, IError { private readonly SdkException _error; /// @@ -64,19 +64,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheListRemoveValueResponse.cs b/src/Momento.Sdk/Responses/CacheListRemoveValueResponse.cs index 3819d642..0165993c 100644 --- a/src/Momento.Sdk/Responses/CacheListRemoveValueResponse.cs +++ b/src/Momento.Sdk/Responses/CacheListRemoveValueResponse.cs @@ -35,7 +35,7 @@ public class Success : CacheListRemoveValueResponse } /// - public class Error : CacheListRemoveValueResponse + public class Error : CacheListRemoveValueResponse, IError { private readonly SdkException _error; @@ -45,19 +45,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheListRetainResponse.cs b/src/Momento.Sdk/Responses/CacheListRetainResponse.cs index a1864688..f6b23b3b 100644 --- a/src/Momento.Sdk/Responses/CacheListRetainResponse.cs +++ b/src/Momento.Sdk/Responses/CacheListRetainResponse.cs @@ -35,7 +35,7 @@ public class Success : CacheListRetainResponse } /// - public class Error : CacheListRetainResponse + public class Error : CacheListRetainResponse, IError { private readonly SdkException _error; @@ -45,19 +45,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheSetAddElementResponse.cs b/src/Momento.Sdk/Responses/CacheSetAddElementResponse.cs index b392d1c2..d1e6cf2d 100644 --- a/src/Momento.Sdk/Responses/CacheSetAddElementResponse.cs +++ b/src/Momento.Sdk/Responses/CacheSetAddElementResponse.cs @@ -35,7 +35,7 @@ public class Success : CacheSetAddElementResponse } /// - public class Error : CacheSetAddElementResponse + public class Error : CacheSetAddElementResponse, IError { private readonly SdkException _error; @@ -45,19 +45,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheSetAddElementsResponse.cs b/src/Momento.Sdk/Responses/CacheSetAddElementsResponse.cs index 9b6f2a14..c01edcaf 100644 --- a/src/Momento.Sdk/Responses/CacheSetAddElementsResponse.cs +++ b/src/Momento.Sdk/Responses/CacheSetAddElementsResponse.cs @@ -35,7 +35,7 @@ public class Success : CacheSetAddElementsResponse } /// - public class Error : CacheSetAddElementsResponse + public class Error : CacheSetAddElementsResponse, IError { private readonly SdkException _error; @@ -45,19 +45,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheSetBatchResponse.cs b/src/Momento.Sdk/Responses/CacheSetBatchResponse.cs index 8accd546..e9a1f792 100644 --- a/src/Momento.Sdk/Responses/CacheSetBatchResponse.cs +++ b/src/Momento.Sdk/Responses/CacheSetBatchResponse.cs @@ -9,7 +9,7 @@ public abstract class CacheSetBatchResponse public class Success : CacheSetBatchResponse { } - public class Error : CacheSetBatchResponse + public class Error : CacheSetBatchResponse, IError { private readonly SdkException _error; public Error(SdkException error) diff --git a/src/Momento.Sdk/Responses/CacheSetFetchResponse.cs b/src/Momento.Sdk/Responses/CacheSetFetchResponse.cs index b65a1a27..2c6957dd 100644 --- a/src/Momento.Sdk/Responses/CacheSetFetchResponse.cs +++ b/src/Momento.Sdk/Responses/CacheSetFetchResponse.cs @@ -98,7 +98,7 @@ public class Miss : CacheSetFetchResponse } /// - public class Error : CacheSetFetchResponse + public class Error : CacheSetFetchResponse, IError { private readonly SdkException _error; @@ -108,19 +108,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheSetIfNotExistsResponse.cs b/src/Momento.Sdk/Responses/CacheSetIfNotExistsResponse.cs index bc62aea9..7bd7ae30 100644 --- a/src/Momento.Sdk/Responses/CacheSetIfNotExistsResponse.cs +++ b/src/Momento.Sdk/Responses/CacheSetIfNotExistsResponse.cs @@ -45,7 +45,7 @@ public class NotStored : CacheSetIfNotExistsResponse } /// - public class Error : CacheSetIfNotExistsResponse + public class Error : CacheSetIfNotExistsResponse, IError { private readonly SdkException _error; @@ -55,19 +55,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheSetRemoveElementResponse.cs b/src/Momento.Sdk/Responses/CacheSetRemoveElementResponse.cs index 85a33071..4884a091 100644 --- a/src/Momento.Sdk/Responses/CacheSetRemoveElementResponse.cs +++ b/src/Momento.Sdk/Responses/CacheSetRemoveElementResponse.cs @@ -35,7 +35,7 @@ public class Success : CacheSetRemoveElementResponse } /// - public class Error : CacheSetRemoveElementResponse + public class Error : CacheSetRemoveElementResponse, IError { private readonly SdkException _error; @@ -45,19 +45,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheSetRemoveElementsResponse.cs b/src/Momento.Sdk/Responses/CacheSetRemoveElementsResponse.cs index e249cb14..8f203632 100644 --- a/src/Momento.Sdk/Responses/CacheSetRemoveElementsResponse.cs +++ b/src/Momento.Sdk/Responses/CacheSetRemoveElementsResponse.cs @@ -35,7 +35,7 @@ public class Success : CacheSetRemoveElementsResponse } /// - public class Error : CacheSetRemoveElementsResponse + public class Error : CacheSetRemoveElementsResponse, IError { private readonly SdkException _error; @@ -45,19 +45,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CacheSetResponse.cs b/src/Momento.Sdk/Responses/CacheSetResponse.cs index e52d920c..06a8e9a5 100644 --- a/src/Momento.Sdk/Responses/CacheSetResponse.cs +++ b/src/Momento.Sdk/Responses/CacheSetResponse.cs @@ -34,7 +34,7 @@ public abstract class CacheSetResponse public class Success : CacheSetResponse { } /// - public class Error : CacheSetResponse + public class Error : CacheSetResponse, IError { private readonly SdkException _error; @@ -44,19 +44,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/CreateCacheResponse.cs b/src/Momento.Sdk/Responses/CreateCacheResponse.cs index 7acfbbd6..13d3ca34 100644 --- a/src/Momento.Sdk/Responses/CreateCacheResponse.cs +++ b/src/Momento.Sdk/Responses/CreateCacheResponse.cs @@ -40,7 +40,7 @@ public class Success : CreateCacheResponse { } public class CacheAlreadyExists : CreateCacheResponse { } /// - public class Error : CreateCacheResponse + public class Error : CreateCacheResponse, IError { private readonly SdkException _error; @@ -50,19 +50,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/DeleteCacheResponse.cs b/src/Momento.Sdk/Responses/DeleteCacheResponse.cs index b2db238b..0a0b0e3e 100644 --- a/src/Momento.Sdk/Responses/DeleteCacheResponse.cs +++ b/src/Momento.Sdk/Responses/DeleteCacheResponse.cs @@ -34,7 +34,7 @@ public abstract class DeleteCacheResponse public class Success : DeleteCacheResponse { } /// - public class Error : DeleteCacheResponse + public class Error : DeleteCacheResponse, IError { private readonly SdkException _error; @@ -44,19 +44,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/FlushCacheResponse.cs b/src/Momento.Sdk/Responses/FlushCacheResponse.cs index 269e749e..a04899ff 100644 --- a/src/Momento.Sdk/Responses/FlushCacheResponse.cs +++ b/src/Momento.Sdk/Responses/FlushCacheResponse.cs @@ -33,7 +33,7 @@ public abstract class FlushCacheResponse public class Success : FlushCacheResponse { } /// - public class Error : FlushCacheResponse + public class Error : FlushCacheResponse, IError { private readonly SdkException _error; @@ -43,19 +43,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/Responses/IError.cs b/src/Momento.Sdk/Responses/IError.cs new file mode 100644 index 00000000..b5c9a136 --- /dev/null +++ b/src/Momento.Sdk/Responses/IError.cs @@ -0,0 +1,33 @@ +using Momento.Sdk.Exceptions; + +namespace Momento.Sdk.Responses; + +/// +/// Represents an error response +/// +public interface IError +{ + /// + /// The object used to construct the response. + /// + SdkException InnerException { get; } + + /// + /// The value for the + /// object. Example:
+ /// + /// if (errorResponse.ErrorCode == MomentoErrorCode.TIMEOUT_ERROR) + /// { + /// // handle timeout error + /// } + /// + ///
+ MomentoErrorCode ErrorCode { get; } + + /// + /// An explanation of conditions that caused and potential + /// ways to resolve the error. + /// + string Message { get; } +} + diff --git a/src/Momento.Sdk/Responses/ListCachesResponse.cs b/src/Momento.Sdk/Responses/ListCachesResponse.cs index a61e42b7..89f92e51 100644 --- a/src/Momento.Sdk/Responses/ListCachesResponse.cs +++ b/src/Momento.Sdk/Responses/ListCachesResponse.cs @@ -66,7 +66,7 @@ public override string ToString() } /// - public class Error : ListCachesResponse + public class Error : ListCachesResponse, IError { private readonly SdkException _error; @@ -76,19 +76,19 @@ public Error(SdkException error) _error = error; } - /// + /// public SdkException InnerException { get => _error; } - /// + /// public MomentoErrorCode ErrorCode { get => _error.ErrorCode; } - /// + /// public string Message { get => $"{_error.MessageWrapper}: {_error.Message}"; diff --git a/src/Momento.Sdk/docs.xml b/src/Momento.Sdk/docs.xml index 8f57f66f..52168a1e 100644 --- a/src/Momento.Sdk/docs.xml +++ b/src/Momento.Sdk/docs.xml @@ -27,29 +27,6 @@ - - - The Momento.Sdk.Exceptions.MomentoErrorCode value for the - Error object. Example:
- - if (errorResponse.ErrorCode == MomentoErrorCode.TIMEOUT_ERROR) - { - // handle timeout error - } - -
-
- - - The SdkException object used to construct the response. - - - - - An explanation of conditions that caused and potential - ways to resolve the error. - -