Navigation Menu

Skip to content
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

Merged
merged 3 commits into from Jan 5, 2018

Conversation

iMouseWu
Copy link
Contributor

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

@@ -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);
Copy link
Member

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.

Copy link
Contributor Author

@iMouseWu iMouseWu Jan 5, 2018

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.

Copy link
Member

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.

Copy link
Contributor Author

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

@harawata harawata changed the title print error detail when xmlConfigBuilder parse error Add XML file path to the exception message when parsing XML mapper failed Jan 5, 2018
@harawata harawata changed the title Add XML file path to the exception message when parsing XML mapper failed Add resource path to the exception message when parsing XML mapper failed Jan 5, 2018
@harawata harawata merged commit f9fabc3 into mybatis:master Jan 5, 2018
@harawata harawata self-assigned this Jan 5, 2018
@harawata harawata added the enhancement Improve a feature or add a new feature label Jan 5, 2018
@harawata harawata added this to the 3.4.6 milestone Jan 5, 2018
@harawata
Copy link
Member

harawata commented Jan 5, 2018

Thank you, @iMouseWu !

pulllock pushed a commit to pulllock/mybatis-3 that referenced this pull request Oct 19, 2023
…iled (mybatis#1172)

* print error detail when xmlConfigBuilder parse error

* modify get location from context to variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve a feature or add a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants