コード例 #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;
        }
コード例 #2
0
 public EmptyInputException(RESTClient client)
     : base(client, null)
 {
 }
コード例 #3
0
 public UserNotFoundException(RESTClient client)
     : base(client, null)
 {
 }
コード例 #4
0
 public UnsupportedRequestMethodException(RESTClient client)
     : base(client, null)
 {
 }
コード例 #5
0
 public UnsupportedVersionException(RESTClient client)
     : base(client, null)
 {
 }
コード例 #6
0
 public UnknownAccessTokenException(RESTClient client, string message)
     : base(client, message)
 {
 }
コード例 #7
0
 public UnsupportedRequestMethodException(RESTClient client, string message)
     : base(client, message)
 {
 }
コード例 #8
0
 public InvalidJSONException(RESTClient client)
     : base(client, null)
 {
 }
コード例 #9
0
 public InvalidSignatureException(RESTClient client, string message)
     : base(client, message)
 {
 }
コード例 #10
0
 public InvalidFieldException(RESTClient client, string itemName)
     : base(client, null, itemName)
 {
 }
コード例 #11
0
 public InvalidJSONException(RESTClient client, string message)
     : base(client, message)
 {
 }
コード例 #12
0
 public InvalidFieldException(RESTClient client, string message, string itemName)
     : base(client, message, itemName)
 {
 }
コード例 #13
0
 public ForbiddenMethodException(RESTClient client)
     : base(client, null)
 {
 }
コード例 #14
0
 public ForbiddenMethodException(RESTClient client, string message)
     : base(client, message)
 {
 }
コード例 #15
0
 public UnauthorizedUserException(RESTClient client, string message)
     : base(client, message)
 {
 }
コード例 #16
0
 public InvalidSignatureException(RESTClient client)
     : base(client, null)
 {
 }
コード例 #17
0
 public UnauthorizedUserException(RESTClient client)
     : base(client, null)
 {
 }
コード例 #18
0
 public MissingFieldException(RESTClient client, string message, string itemName)
     : base(client, "Missing field: " + itemName)
 {
     this.itemName = itemName;
 }
コード例 #19
0
 public UnknownAccessTokenException(RESTClient client)
     : base(client, null)
 {
 }
コード例 #20
0
 public MissingFieldException(RESTClient client, string itemName)
     : this(client, null, itemName)
 {
 }
コード例 #21
0
 /// <summary>
 /// Construct the exception instance.
 /// </summary>
 /// <param name="client">REST client instance.</param>
 public APIException(RESTClient client)
     : this(client, null)
 {
 }
コード例 #22
0
 public MissingHeaderException(RESTClient client, string message, string itemName)
     : base(client, message, itemName)
 {
 }
コード例 #23
0
 public UnsupportedVersionException(RESTClient client, string message)
     : base(client, message)
 {
 }
コード例 #24
0
 public MissingHeaderException(RESTClient client, string itemName)
     : base(client, null, itemName)
 {
 }
コード例 #25
0
 public UserNotFoundException(RESTClient client, string message)
     : base(client, message)
 {
 }
コード例 #26
0
 public SessionRestoreException(RESTClient client, string message)
     : base(client, message)
 {
 }
コード例 #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();
 }
コード例 #28
0
 public SessionRestoreException(RESTClient client)
     : base(client, null)
 {
 }
コード例 #29
0
ファイル: APIMethod.cs プロジェクト: Rublon/rublon-sdk-dotnet
 /// <summary>
 /// Construct the API method instance.
 /// </summary>
 /// <param name="rublon"></param>
 public APIMethod(RublonConsumer rublon)
 {
     this.rublon = rublon;
     client = new RESTClient(rublon);
 }
コード例 #30
0
 public EmptyInputException(RESTClient client, string message)
     : base(client, message)
 {
 }