using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ServerCore; using ServerBase; namespace ServerBase; public class DynamoDbQueryExceptionNotifier { public const string Success = "None"; // 쿼리 성공 public const string ConditionalCheckFailed = "ConditionalCheckFailed"; // 쿼리 실패 : 조건들이 충족하지 못해 실패 했다. public const string ItemCollectionSizeLimitExceeded = "ItemCollectionSizeLimitExceeded"; // 쿼리 실패 : 아이템 제한 개수 초과로 실패 했다. public class ExceptionHandler { public ExceptionHandler(string reasonCode, ServerErrorCode returnToErrorCode) { ReasonCode = reasonCode; ReturnToErrorCode = returnToErrorCode; } public bool hasReasonCode(string reasonCode) { return ReasonCode.Equals(reasonCode, StringComparison.OrdinalIgnoreCase); } public string ReasonCode { get; set; } public ServerErrorCode ReturnToErrorCode { get; set; } } private Int32 m_query_seq_no = 0; private readonly Dictionary m_exception_handlers = new(); public DynamoDbQueryExceptionNotifier() { } public bool registerExceptionHandler(ExceptionHandler? exceptionHandler) { m_query_seq_no++; if(null == exceptionHandler) { return false; } if(true == m_exception_handlers.ContainsKey(m_query_seq_no)) { return false; } m_exception_handlers[m_query_seq_no] = exceptionHandler; return true; } public ExceptionHandler? findExceptionHandler(Int32 querySeqNo, string reasonCode) { if(false == m_exception_handlers.TryGetValue(querySeqNo, out var exception_handler)) { return null; } if(false == exception_handler.hasReasonCode(reasonCode)) { return null; } return exception_handler; } }