protected BinanceApiResult <T> ThrowErrorMessage <T>(BinanceError error, string extraInformation)
        {
            log.Write(LogVerbosity.Warning, $"Call failed: {error.Message}");
            var result = (BinanceApiResult <T>)Activator.CreateInstance(typeof(BinanceApiResult <T>));

            result.Error = error;
            if (extraInformation != null)
            {
                result.Error.Message += Environment.NewLine + extraInformation;
            }
            return(result);
        }
Esempio n. 2
0
        private BinanceException CreateBinanceException(HttpStatusCode statusCode, BinanceError errorObject)
        {
            if (statusCode == HttpStatusCode.GatewayTimeout)
            {
                return(new BinanceTimeoutException(errorObject));
            }
            var parsedStatusCode = (int)statusCode;

            if (parsedStatusCode >= 400 && parsedStatusCode <= 500)
            {
                return(new BinanceBadRequestException(errorObject));
            }
            return(parsedStatusCode >= 500
                ? new BinanceServerException(errorObject)
                : new BinanceException("Binance API Error", errorObject));
        }
 public BinanceTimeoutException(BinanceError errorDetails) : base((string)" request was valid, the server went to execute but then timed out. This doesn't mean it failed, and should be treated as UNKNOWN.", errorDetails)
 {
 }
 public BinanceBadRequestException(BinanceError errorDetails) : base((string)"Malformed requests are sent to the server. Please review the request object/string", errorDetails)
 {
 }
 public BinanceServerException(BinanceError errorDetails) : base((string)"Request to BinanceAPI is valid but there was an error on the server side", errorDetails)
 {
 }
 protected BinanceApiResult <T> ThrowErrorMessage <T>(BinanceError error)
 {
     return(ThrowErrorMessage <T>(error, null));
 }