Permalink
Browse files

Merge pull request #67 from dragos/issue/unclosed-comment-66

Don't create errors at negative offsets.
  • Loading branch information...
2 parents cb429a2 + fdd033b commit 25189ca34b16918a85225852bbe93a85f3d60969 @dragos dragos committed Apr 4, 2013
@@ -59,6 +59,15 @@ class TemplateCompilationUnitTest {
assertTrue(tu.generatedSource.isFailure)
}
+ @Test
+ def error_on_position_zero_no_crash() {
+ val tFile = file("app/views/template_unclosed_comment.scala.html")
+ val tu = TemplateCompilationUnit(tFile)
+ val errors = tu.reconcile(tu.getTemplateContents.toString)
+ assertEquals("Unexpected errors", 1, errors.size)
+ assertTrue("Negative offset", errors.head.getSourceStart() >= 0)
+ }
+
@Test
def scala_source_is_generated_when_there_are_scala_compiler__errors() {
val tFile = file("app/views/scala_compiler_error.scala.html")
@@ -0,0 +1,7 @@
+@*
+
+@(message: String)
+
+@main("Welcome") {
+ <p>@</p>
+}
@@ -60,8 +60,8 @@ case class TemplateToScalaCompilationError(source: File, message: String, offset
0,
Array.empty[String],
severityLevel,
- offset - 1,
- offset - 1,
+ Math.max(offset - 1, 0),
+ Math.max(offset - 1, 0),
line,
column)
}
@@ -85,7 +85,7 @@ class TemplatePresentationCompiler(playProject: PlayProject) extends HasLogger {
private def unknownError(tcu: TemplateCompilationUnit, error: Throwable): IProblem = {
val severityLevel = ProblemSeverities.Error
- val message = error.getMessage()
+ val message = s"${error.getMessage()} - ${error.getClass()}"
new DefaultProblem(
tcu.getTemplateFullPath.toCharArray(),
message,

0 comments on commit 25189ca

Please sign in to comment.