私のtryブロックのコードは次のようになります。
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 が満たされ、スローされます。ただし、デバッグ中に外部 WebProtocolException もスローされ、「A の WebProtocolException CustomerID が B の customerId と一致しません。ユーザー コードによって処理されませんでした」というメッセージが表示されます。
ただし、フィドラーを確認すると、400 のステータス コードが表示され、フィドラーの raw タブに、メッセージとともに正しい badrequest 応答が表示されます。
2 番目の WebProtocol がユーザー コードによって処理されない理由がわかりません。
どんな提案でも大歓迎です!
ザル