2011-07-27 132 views
0

我try塊中的代碼看起來像下面的東西:WebProtocolException是未處理由用戶代碼

catch (ThinkBusinessLogicException ex) 
{ 
    var message = (ex.InnerException != null) ? ex.InnerException.ToString() : ex.Message; 

    if (message == "CustomerID in A does not match customerId in B") 
    { 
     Error = new ErrorStore("400", "1", "CustomerID in A does not match customerId in B"); 
     throw new WebProtocolException(HttpStatusCode.BadRequest, Error.Description, Error.Generate(), null, null); 
    } 

    throw new WebProtocolException(HttpStatusCode.InternalServerError, message, new ErrorStore("500", "1", message).Generate(), null, null); 
} 

什麼情況是,滿足條件,並在條件WebProtolException滿足和拋出。然而,在調試outter時,WebProtocolException也被拋出,聲明「A中的WebProtocolException CustomerID與用戶代碼未處理的B中的customerId不匹配」。

但是,當我看看小提琴手時,會顯示400的狀態碼,並在小提琴手的原始選項卡上顯示正確的具有該信息的badrequest響應。

我很困惑爲什麼第二個WebProtocol未被用戶代碼處理。

任何建議,非常感謝!

扎爾

回答

相關問題