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

Improve View Template Error Message #1178

Merged
merged 1 commit into from Sep 1, 2015

Conversation

Projects
None yet
3 participants
@nickbabcock
Contributor

nickbabcock commented Jul 21, 2015

Instead of hiding behind a sometimes deceptive error message saying that the
template file was not found, propagate the error message in an HTML safe
way
return a generic error message with the actual error going to the log
file. This makes the behavior more in line with validation errors (though this
doesn't deal with validation errors, itself)

Closes #1077

@nickbabcock nickbabcock force-pushed the nickbabcock:mustache branch 2 times, most recently from be4054b to 3546b6f Jul 27, 2015

@nickbabcock

This comment has been minimized.

Contributor

nickbabcock commented Jul 27, 2015

So based on @nathancomstock's comment, I've refocused the pull request such that instead of throwing up an error page that says that the file isn't found, return a generic page to the client saying that something went wrong. Then the developer can see the error under debug mode.

This pull request also explains the behavior in the views documentation.

@@ -77,11 +78,11 @@ public void writeTo(View t,
}
}
throw new ViewRenderException("Unable to find a renderer for " + t.getTemplateName());
} catch (FileNotFoundException e) {
final String msg = MessageFormat.format(MISSING_TEMPLATE_MSG, t.getTemplateName());
} catch (Throwable e) {

This comment has been minimized.

@joschi

joschi Jul 28, 2015

Member

Catching Throwable instead of just Exception might be too broad here as it also catches non-recoverable errors like OutOfMemoryError.

Improve View Template Error Message
Instead of hiding behind a sometimes deceptive error message saying that
the template file was not found, return a generic HTML message to the
client.

Note in the documentation that the actual error message can be retrieved
under debug mode.

@nickbabcock nickbabcock force-pushed the nickbabcock:mustache branch from 3546b6f to eaea76a Jul 28, 2015

@nickbabcock

This comment has been minimized.

Contributor

nickbabcock commented Jul 28, 2015

Oi, good catch. Fixed 😊

arteam added a commit that referenced this pull request Sep 1, 2015

Merge pull request #1178 from nickbabcock/mustache
Improve View Template Error Message

@arteam arteam merged commit 5072444 into dropwizard:master Sep 1, 2015

@arteam

This comment has been minimized.

Member

arteam commented Sep 1, 2015

LGTM!

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