2017-03-29 7 views

答えて

2

次のようにエラー情報を格納するクラスを1つ作成します。

ErrorInformation objError = new ErrorInformation(); 

try 
{ 
    test(ref Token, ref SessionToken); 
} 
catch (Exception ex) 
{ 
    objError.ErrorMessage = ex.Message; 
    objError.StatusCode = Convert.ToInt16(HttpStatusCode.ExpectationFailed); 
    objError.ErrorType = ex.GetType().ToString(); 
    objError.ErrorCode = "E01"; 

    throw new HttpResponseException(Request.CreateResponse<ErrorInformation>(HttpStatusCode.ExpectationFailed, objError)); 
} 

これは結果としてオブジェクト全体を返します。

{ 
    "StatusCode": 417, 
    "ErrorMessage": "Error Detail", 
    "ErrorType": "System.DivideByZeroException", 
    "ErrorCode": "E01" 
} 
+0

はい作業しています... – Krunal

+0

助けて嬉しいです –

関連する問題