Skip to content

Commit

Permalink
feat(core/utils/wechat-mp): log when error
Browse files Browse the repository at this point in the history
Prevent errors from being completely suppressed if the caller catches
them.

Signed-off-by: Rongrong <[email protected]>
  • Loading branch information
Rongronggg9 committed Apr 21, 2024
1 parent 428e65c commit 58b836c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/utils/wechat-mp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ const formatLog = (...params: string[]): string => `${formatLogNoMention(...para
Consider raise an issue (mentioning ${MAINTAINERS.join(', ')}) with the article URL for further investigation`;
let warn = (...params: string[]) => logger.warn(formatLog(...params));
const error = (...params: string[]): never => {
throw new WeChatMpError(formatLog(...params));
const msg = formatLog(...params);
logger.error(msg);
throw new WeChatMpError(msg);
};
const errorNoMention = (...params: string[]): never => {
throw new WeChatMpError(formatLogNoMention(...params));
const msg = formatLogNoMention(...params);
logger.error(msg);
throw new WeChatMpError(msg);
};
const toggleWerror = (() => {
const onFunc = (...params: string[]) => error('WarningAsError', ...params);
Expand Down

0 comments on commit 58b836c

Please sign in to comment.