Skip to content

fix: change the way to check a type whether a exception - #106

Merged
gxcsoccer merged 1 commit into
1.xfrom
fix-exception-identify
May 21, 2018
Merged

fix: change the way to check a type whether a exception#106
gxcsoccer merged 1 commit into
1.xfrom
fix-exception-identify

Conversation

@gxcsoccer

@gxcsoccer gxcsoccer commented May 21, 2018

Copy link
Copy Markdown
Member

以前根据正则来判断不太严谨,上周大佬们开发时候,服务端一个异常对象叫 ErrorContext 不是 Exception 结尾的,没有识别出来,导致错误栈打出来比较奇怪

@gxcsoccer
gxcsoccer force-pushed the fix-exception-identify branch from 8d87fb1 to 3d57587 Compare May 21, 2018 08:30
@fengmk2

fengmk2 commented May 21, 2018

Copy link
Copy Markdown
Member

能100%兼容原来的逻辑吗?可以的话+1

@gxcsoccer

gxcsoccer commented May 21, 2018

Copy link
Copy Markdown
Member Author

能100%兼容原来的逻辑吗?可以的话+1

这个不好说,以前是根据名字来判断 Exception 类,现在换一种方式根据属性来判断。

只能说觉得目前的方式准确率会高一点,但是也不排除有些变态的类刚好包含 Exception 基类的属性

以前应该是 100%,因为如果以前判断出来是 Exception(前提是没判断错),那用现在判断出来肯定也是 Exception。唯一的问题在于,如果遇到变态的 class,包含和 Exception 基类一样的属性,这样可能会误判断为 exception 来处理

@gxcsoccer
gxcsoccer merged commit 2a67803 into 1.x May 21, 2018
@gxcsoccer
gxcsoccer deleted the fix-exception-identify branch May 21, 2018 10:05
@gxcsoccer

Copy link
Copy Markdown
Member Author

1.8.2

Comment thread lib/v2/decoder.js
}
}
if (/Exception$/.test(classname)) {
if (errorPropCount === 3) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic Number 是否要常量化一下?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么是 3,没有注释说明一下?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants