Exemplo n.º 1
0
        /// <summary>
        /// Create the APIException instance by the API response.
        /// </summary>
        /// <param name="client">REST client instance.</param>
        /// <returns></returns>
        public static APIException Factory(RESTClient client)
        {
            APIException resultException = null;
            var rawRsponse = client.RawResponse;
            var response = JObject.Parse(rawRsponse);
            if (response != null)
            {
                var status = response.Value<string>(APIMethod.FIELD_STATUS);
                if (status != null && status == APIMethod.STATUS_ERROR)
                {
                    var result = response.Value<JObject>(APIMethod.FIELD_RESULT);
                    if (result != null)
                    {
                        var exception = result.Value<string>(FIELD_EXCEPTION);
                        if (exception != null)
                        {
                            var message = result.Value<string>(FIELD_MESSAGE);
                            var itemName = result.Value<string>(FIELD_ITEM_NAME);
                            if (!string.IsNullOrEmpty(message) && !string.IsNullOrEmpty(itemName))
                            {
                                resultException = Factory(exception, new object[] { client, message, itemName });
                            }
                            else if (!string.IsNullOrEmpty(message))
                            {
                                resultException = Factory(exception, new object[] { client, message });
                            }
                            else
                            {
                                resultException = Factory(exception, new object[] { client });
                            }
                        }
                    }
                }
            }

            if (resultException == null)
            {
                resultException = new APIException(client);
            }

            return resultException;
        }
Exemplo n.º 2
0
 public EmptyInputException(RESTClient client)
     : base(client, null)
 {
 }
Exemplo n.º 3
0
 public UserNotFoundException(RESTClient client)
     : base(client, null)
 {
 }
Exemplo n.º 4
0
 public UnsupportedRequestMethodException(RESTClient client)
     : base(client, null)
 {
 }
Exemplo n.º 5
0
 public UnsupportedVersionException(RESTClient client)
     : base(client, null)
 {
 }
Exemplo n.º 6
0
 public UnknownAccessTokenException(RESTClient client, string message)
     : base(client, message)
 {
 }
Exemplo n.º 7
0
 public UnsupportedRequestMethodException(RESTClient client, string message)
     : base(client, message)
 {
 }
Exemplo n.º 8
0
 public InvalidJSONException(RESTClient client)
     : base(client, null)
 {
 }
Exemplo n.º 9
0
 public InvalidSignatureException(RESTClient client, string message)
     : base(client, message)
 {
 }
Exemplo n.º 10
0
 public InvalidFieldException(RESTClient client, string itemName)
     : base(client, null, itemName)
 {
 }
Exemplo n.º 11
0
 public InvalidJSONException(RESTClient client, string message)
     : base(client, message)
 {
 }
Exemplo n.º 12
0
 public InvalidFieldException(RESTClient client, string message, string itemName)
     : base(client, message, itemName)
 {
 }
Exemplo n.º 13
0
 public ForbiddenMethodException(RESTClient client)
     : base(client, null)
 {
 }
Exemplo n.º 14
0
 public ForbiddenMethodException(RESTClient client, string message)
     : base(client, message)
 {
 }
Exemplo n.º 15
0
 public UnauthorizedUserException(RESTClient client, string message)
     : base(client, message)
 {
 }
Exemplo n.º 16
0
 public InvalidSignatureException(RESTClient client)
     : base(client, null)
 {
 }
Exemplo n.º 17
0
 public UnauthorizedUserException(RESTClient client)
     : base(client, null)
 {
 }
Exemplo n.º 18
0
 public MissingFieldException(RESTClient client, string message, string itemName)
     : base(client, "Missing field: " + itemName)
 {
     this.itemName = itemName;
 }
Exemplo n.º 19
0
 public UnknownAccessTokenException(RESTClient client)
     : base(client, null)
 {
 }
Exemplo n.º 20
0
 public MissingFieldException(RESTClient client, string itemName)
     : this(client, null, itemName)
 {
 }
Exemplo n.º 21
0
 /// <summary>
 /// Construct the exception instance.
 /// </summary>
 /// <param name="client">REST client instance.</param>
 public APIException(RESTClient client)
     : this(client, null)
 {
 }
Exemplo n.º 22
0
 public MissingHeaderException(RESTClient client, string message, string itemName)
     : base(client, message, itemName)
 {
 }
Exemplo n.º 23
0
 public UnsupportedVersionException(RESTClient client, string message)
     : base(client, message)
 {
 }
Exemplo n.º 24
0
 public MissingHeaderException(RESTClient client, string itemName)
     : base(client, null, itemName)
 {
 }
Exemplo n.º 25
0
 public UserNotFoundException(RESTClient client, string message)
     : base(client, message)
 {
 }
Exemplo n.º 26
0
 public SessionRestoreException(RESTClient client, string message)
     : base(client, message)
 {
 }
Exemplo n.º 27
0
 /// <summary>
 /// Construct the exception instance.
 /// </summary>
 /// <param name="client">REST client instance.</param>
 /// <param name="message">Exception message.</param>
 public APIException(RESTClient client, string message)
     : base(message)
 {
     this.client = client;
     prepareExceptionsMap();
 }
Exemplo n.º 28
0
 public SessionRestoreException(RESTClient client)
     : base(client, null)
 {
 }
Exemplo n.º 29
0
 /// <summary>
 /// Construct the API method instance.
 /// </summary>
 /// <param name="rublon"></param>
 public APIMethod(RublonConsumer rublon)
 {
     this.rublon = rublon;
     client = new RESTClient(rublon);
 }
Exemplo n.º 30
0
 public EmptyInputException(RESTClient client, string message)
     : base(client, message)
 {
 }