/// <summary> /// Creates error response with well-known transaction execution error code /// </summary> public static BlockchainErrorResponse FromKnownError(BlockchainErrorCode code) { string GetMessage() { switch (code) { case BlockchainErrorCode.Unknown: throw new ArgumentOutOfRangeException(nameof(code), code, "Error code should be well-known"); case BlockchainErrorCode.AmountIsTooSmall: return("Amount is to small to execute transaction"); case BlockchainErrorCode.NotEnoughtBalance: return("Not enought balance on the source address to execute transaction"); default: throw new ArgumentOutOfRangeException(nameof(code), code, null); } } return(new BlockchainErrorResponse { ErrorCode = code, ErrorMessage = GetMessage(), ModelErrors = new Dictionary <string, List <string> >() }); }
public static StellarErrorResponse Create(string message, BlockchainErrorCode errorCode) { //TODO: Fix that bug if (errorCode == BlockchainErrorCode.Unknown) { errorCode = BlockchainErrorCode.AmountIsTooSmall; } return(new StellarErrorResponse(message, errorCode)); }
private StellarErrorResponse(string errorMessage, BlockchainErrorCode errorCode) { //TODO: Fix that bug if (errorCode == BlockchainErrorCode.Unknown) { errorCode = BlockchainErrorCode.AmountIsTooSmall; } ErrorMessage = errorMessage; ErrorCode = errorCode; ModelErrors = new Dictionary <string, List <string> >(); }
public static TransactionBroadcastingResult FromErrorCode(BlockchainErrorCode errorCode) { switch (errorCode) { case BlockchainErrorCode.AmountIsTooSmall: return(TransactionBroadcastingResult.AmountIsTooSmall); case BlockchainErrorCode.NotEnoughtBalance: return(TransactionBroadcastingResult.NotEnoughBalance); case BlockchainErrorCode.Unknown: default: throw new ResultValidationException("Invalid error code", errorCode); } }
public static TransactionExecutionResult MapToTransactionExecutionResult( this BlockchainErrorCode source) { switch (source) { case BlockchainErrorCode.AmountIsTooSmall: return(TransactionExecutionResult.AmountIsTooSmall); case BlockchainErrorCode.NotEnoughBalance: return(TransactionExecutionResult.NotEnoughBalance); case BlockchainErrorCode.Unknown: return(TransactionExecutionResult.UnknownError); case BlockchainErrorCode.BuildingShouldBeRepeated: return(TransactionExecutionResult.RebuildingIsRequired); default: throw new ArgumentOutOfRangeException(nameof(source), source, null); } }
private StellarErrorResponse(string errorMessage, BlockchainErrorCode errorCode) { ErrorMessage = errorMessage; ErrorCode = errorCode; ModelErrors = new Dictionary <string, List <string> >(); }
public BlockchainException(BlockchainErrorCode errorCode, string message) : base(message) => ErrorCode = errorCode;
public static BlockchainTransaction Failed(string error, BlockchainErrorCode errorCode) => new BlockchainTransaction { State = BroadcastedTransactionState.Failed, Error = error, ErrorCode = errorCode };
public static StellarErrorResponse Create(string message, BlockchainErrorCode errorCode) { return(new StellarErrorResponse(message, errorCode)); }