JeffreySu/WeiXinMPSDK · error · MessageHandlerException
ThirdPartyMessageHandler中ExecuteAsync()过程发生错误:
Error message
ThirdPartyMessageHandler中ExecuteAsync()过程发生错误:
What it means
ExecuteAsync wraps all message dispatch in a try-catch and rethrows any exception as MessageHandlerException with the message 'ThirdPartyMessageHandler中ExecuteAsync()过程发生错误:' + the inner message. This is a wrapper error: the root cause (e.g. error [74], a handler callback throwing, XML parsing) is in the InnerException.
Solutions
- Inspect ex.InnerException — the real error (e.g. UnknownRequestMsgTypeException with the InfoType) is there.
- Fix the root cause: upgrade the SDK for unknown InfoTypes, or fix the throwing On*Async callback.
- Log full exception with inner chain in your OnExecuted/error logging instead of only ex.Message.
Example fix
// before
catch (MessageHandlerException ex)
{
logger.LogError(ex.Message);
}
// after
catch (MessageHandlerException ex)
{
logger.LogError(ex, "ThirdParty handler failed: {Inner}", ex.InnerException?.ToString());
} Defensive patterns
Strategy: try-catch
Try / catch
try { await handler.ExecuteAsync(ct); }
catch (MessageHandlerException ex)
{ logger.LogError(ex.InnerException ?? ex, "Third-party handler root cause: {Msg}", ex.InnerException?.Message); } Prevention
- Always log InnerException for MessageHandlerException — the wrapper message is not actionable.
- Wrap individual On*Async callbacks with their own error handling so failures are localized.
- Test the handler with recorded WeChat push payloads in CI.
When it happens
Trigger: Any exception inside ThirdPartyMessageHandlerAsync.ExecuteAsync — unknown InfoType, null request message, user-registered On*Async callbacks throwing, or serialization failures during third-party message processing.
Common situations: Debugging why a WeChat component push returns an error; the surfaced message alone ('...发生错误:') is unhelpful because the true cause is nested inside InnerException.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/420237d67e7f5fb0.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.Open/Senparc.Weixin.Open/MessageHandlers/ThirdPartyMessageHandlerAsync.cs:154
{
var requestMessage = RequestMessage as RequestMessageOrderPathApplyResultNotify;
ResponseMessageText = await OnOrderPathApplyResultNotifyRequestAsync(requestMessage, cancellationToken);
}
break;
case RequestInfoType.order_path_audit_result_notify:
{
var requestMessage = RequestMessage as RequestMessageOrderPathAuditResultNotify;
ResponseMessageText = await OnOrderPathAuditResultNotifyRequestAsync(requestMessage, cancellationToken);
}
break;
default:
throw new UnknownRequestMsgTypeException("未知的InfoType请求类型", null);
}
}
catch (Exception ex)
{
throw new MessageHandlerException("ThirdPartyMessageHandler中ExecuteAsync()过程发生错误:" + ex.Message, ex);
}
finally
{
await OnExecutedAsync(cancellationToken);
}
}
public virtual Task OnExecutingAsync(CancellationToken cancellationToken)
{
OnExecuting();
return Task.CompletedTask;
}
public virtual Task OnExecutedAsync(CancellationToken cancellationToken)
{
OnExecuted();
return Task.CompletedTask;
}View on GitHub (pinned to be573f6f94)