Пример #1
0
            public void PaserServerError(Stream inputStream, string contentType, long contentLength)
            {
                CosServerException cosServerException = new CosServerException(cosResult.httpCode, cosResult.httpMessage);
                List <string>      values;

                Headers.TryGetValue("x-cos-request-id", out values);
                cosServerException.requestId = (values != null && values.Count > 0) ? values[0] : null;
                Headers.TryGetValue("x-cos-trace-id", out values);
                cosServerException.traceId = (values != null && values.Count > 0) ? values[0] : null;
                if (inputStream != null && contentLength > 0)
                {
                    CosServerError cosServerError = new CosServerError();
                    try
                    {
                        XmlParse.ParseCosError(inputStream, cosServerError);
                        if (cosServerException.requestId != null)
                        {
                            cosServerException.requestId = cosServerError.requestId;
                        }
                        if (cosServerException.traceId != null)
                        {
                            cosServerException.traceId = cosServerError.traceId;
                        }
                        cosServerException.resource     = cosServerError.resource;
                        cosServerException.errorCode    = cosServerError.code;
                        cosServerException.errorMessage = cosServerError.message;
                    }
                    catch (Exception ex)
                    {
                        QLog.D(TAG, ex.Message);
                    }
                }
                throw cosServerException;
            }
Пример #2
0
            public void PaserServerError(Stream inputStream, string contentType, long contentLength)
            {
                CosServerException cosServerException = new CosServerException(cosResult.httpCode, cosResult.httpMessage);
                List <string>      values;

                Headers.TryGetValue("x-cos-request-id", out values);
                cosServerException.requestId = (values != null && values.Count > 0) ? values[0] : null;
                Headers.TryGetValue("x-cos-trace-id", out values);
                cosServerException.traceId = (values != null && values.Count > 0) ? values[0] : null;

                if (inputStream != null)
                {
                    try
                    {
                        CosServerError cosServerError = XmlParse.Deserialize <CosServerError>(inputStream);

                        cosServerException.SetCosServerError(cosServerError);
                    }
                    catch (Exception ex)
                    {
                        QLog.Debug(TAG, ex.Message);
                    }
                }

                throw cosServerException;
            }
Пример #3
0
 public void SetCosServerError(CosServerError serverError)
 {
     if (serverError != null)
     {
         this.resource     = serverError.resource;
         this.errorCode    = serverError.code;
         this.errorMessage = serverError.message;
         this.requestId    = serverError.requestId;
         this.traceId      = serverError.traceId;
     }
 }
Пример #4
0
 public CosServerException(int statusCode, string statusMessage, CosServerError serverError)
     : this(statusCode, statusMessage)
 {
     if (serverError != null)
     {
         this.resource     = serverError.resource;
         this.errorCode    = serverError.code;
         this.errorMessage = serverError.message;
         this.requestId    = serverError.requestId;
         this.traceId      = serverError.traceId;
     }
 }