From: James Moger Date: Fri, 5 Oct 2012 12:16:11 +0000 (-0400) Subject: Catch all exceptions from MarkdownPapers and rethrow as ParseException (issue 142) X-Git-Tag: v1.2.0~179 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=88aad76a0e54b4a8757bbc9ea45fec8f70baa832;p=gitblit.git Catch all exceptions from MarkdownPapers and rethrow as ParseException (issue 142) --- diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd index ffd56ddc..55bdfd71 100644 --- a/docs/04_releases.mkd +++ b/docs/04_releases.mkd @@ -11,6 +11,7 @@ If you are updating from an earlier release AND you have indexed branches with t #### fixes +- Wrapped Markdown parser with improved exception handler (issue 142) - Fixed duplicate entries in repository cache (issue 140) - Fixed connection leak in LDAPUserService (issue 139) - Fixed bug in commit page where changes to a submodule threw a null pointer exception (issue 132) diff --git a/src/com/gitblit/utils/MarkdownUtils.java b/src/com/gitblit/utils/MarkdownUtils.java index 828225db..0b8c9c57 100644 --- a/src/com/gitblit/utils/MarkdownUtils.java +++ b/src/com/gitblit/utils/MarkdownUtils.java @@ -67,9 +67,15 @@ public class MarkdownUtils { Markdown md = new Markdown(); md.transform(markdownReader, writer); return writer.toString().trim(); + } catch (StringIndexOutOfBoundsException e) { + LoggerFactory.getLogger(MarkdownUtils.class).error("MarkdownPapers failed to parse Markdown!", e); + throw new java.text.ParseException(e.getMessage(), 0); } catch (ParseException p) { LoggerFactory.getLogger(MarkdownUtils.class).error("MarkdownPapers failed to parse Markdown!", p); throw new java.text.ParseException(p.getMessage(), 0); + } catch (Exception e) { + LoggerFactory.getLogger(MarkdownUtils.class).error("MarkdownPapers failed to parse Markdown!", e); + throw new java.text.ParseException(e.getMessage(), 0); } finally { try { writer.close();