コード例 #1
0
        private string FormatApiExceptionForWriting(string message, ApiException ex)
        {
            string info = string.Format("{0}, Status: {1}, API Error Msg: {2}", ex.Message, ex.StatusCode,
                                        ex.ApiError.Message);

            return(string.Format("{0} {1}: {2}", message, ex.GetType().Name, info));
        }
コード例 #2
0
        public void ThrowsWhenExceptionsWhichShouldCauseRethrowAreCaught(ApiException exception)
        {
            Exception caughtException = null;

            try
            {
                state.Start(exception).Wait();
            }
            catch (Exception e)
            {
                caughtException = e;
            }

            caughtException.Should().NotBeNull();
            caughtException.Should().BeAssignableTo(exception.GetType());
        }
コード例 #3
0
        private Task HandleForgeAPIExceptionAsync(HttpContext context, ApiException e)
        {
            context.Response.ContentType = "application/json";
            string  message      = "";
            dynamic errorContent = null;

            if (e.GetType() == typeof(ApiException))
            {
                context.Response.StatusCode = e.ErrorCode;
                message      = e.Message;
                errorContent = e.ErrorContent;
            }

            var response = context.Response.WriteAsync(new ForgeApiErrorDetails
            {
                errorContent = errorContent,
                message      = message,
                code         = context.Response.StatusCode
            }.ToString());

            return(response);
        }
コード例 #4
0
 public JsonApiResult(ApiException ex)
 {
     this.Status  = "Error";
     this.Type    = ex.GetType().ToString();
     this.Message = ex.Message;
 }