-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add resource path to the exception message when parsing XML mapper failed #1172
Conversation
@@ -117,7 +117,7 @@ private void configurationElement(XNode context) { | |||
sqlElement(context.evalNodes("/mapper/sql")); | |||
buildStatementFromContext(context.evalNodes("select|insert|update|delete")); | |||
} catch (Exception e) { | |||
throw new BuilderException("Error parsing Mapper XML. Cause: " + e, e); | |||
throw new BuilderException("Error parsing Mapper XML." + ErrorContext.instance() + " Cause: " + e, e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better not to use ErrorContext
.
The mapper file location is in this.resource
, so please use it to build the message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to use resource
than ErrorContext
In this case,because nobody knows how much infomation the context contains .Also it is the weakness to use context( For example
Chain of Responsibility
)
But I am curious about the code design of ErrorContext
.I'm puzzled about using ErrorContext
,I can find putting the infomation in it,but I cannot find where to get the infomation
Thank You.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used in ExceptionFactory#wrapException()
, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your prompt answer
Thank you, @iMouseWu ! |
…iled (mybatis#1172) * print error detail when xmlConfigBuilder parse error * modify get location from context to variables
when xmlConfigBuilder parse xml file error,the stack of the error will not identify which file it is.
I think printing error detail in threadLocal may be more friendly for developers
I can not agree more that putting the error message in the core @harawata
see another PR