@@ -34,6 +34,7 @@ import org.knime.core.data.`def`.DoubleCell
3434import org .knime .core .data .`def` .IntCell
3535import org .knime .ext .jruby .preferences .PreferenceConstants
3636import scala .collection .JavaConversions ._
37+ import scala .util .matching .Regex
3738
3839object RubyScriptNodeModel {
3940
@@ -356,34 +357,49 @@ end
356357 private def findErrorSource (thr : Throwable , filename : String ): Int = {
357358 val err = thr.getMessage
358359 if (err.startsWith(" (SyntaxError)" )) {
359- val pLineS = Pattern .compile(" (?<=:)(\\ d+):(.*)" )
360- val mLine = pLineS.matcher(err)
361- if (mLine.find()) {
362- logger.debug(" SyntaxError error line: " + mLine.group(1 ))
363- script_error.text = if (mLine.group(2 ) == null ) script_error.text else mLine.group(2 )
364- logger.debug(" SyntaxError: " + script_error.text)
365- script_error.lineNum = java.lang.Integer .parseInt(mLine.group(1 ))
366- script_error.columnNum = - 1
367- script_error.`type` = " SyntaxError"
360+ // val pLineS = Pattern.compile("(?<=:)(\\d+):(.*)")
361+ // val mLine = pLineS.matcher(err)
362+ // if (mLine.find()) {
363+ // logger.debug("SyntaxError error line: " + mLine.group(1))
364+ // script_error.text = if (mLine.group(2) == null) script_error.text else mLine.group(2)
365+ // logger.debug("SyntaxError: " + script_error.text)
366+ // script_error.lineNum = java.lang.Integer.parseInt(mLine.group(1))
367+ // script_error.columnNum = -1
368+ // script_error.`type` = "SyntaxError"
369+ // }
370+ val pLineS = """ (?<=:)(\d+):(.*)""" .r
371+ err match {
372+ case pLineS(line, text) =>
373+ logger.debug(" SyntaxError error line: " + line)
374+ if (text != null ) script_error.text = text
375+ logger.debug(" SyntaxError: " + script_error.text)
376+ script_error.lineNum = line.toInt
377+ script_error.columnNum = - 1
378+ script_error.`type` = " SyntaxError"
368379 }
380+
369381 } else {
370- val `type` = Pattern .compile(" (?<=\\ ()(\\ w*)" )
371- val mLine = `type`.matcher(err)
372- if (mLine.find()) {
373- script_error.`type` = mLine.group(1 )
374- }
382+ // val `type` = Pattern.compile("(?<=\\()(\\w*)")
383+ // val mLine = `type`.matcher(err)
384+ // if (mLine.find()) {
385+ // script_error.`type` = mLine.group(1)
386+ // }
387+ script_error.`type` = """ (?<=\()(\w*)""" .r
388+ .findFirstMatchIn(err).map(_ group 2 ).getOrElse(script_error.`type`)
389+
375390 val cause = thr.getCause
376391 for (line <- cause.getStackTrace if line.getFileName == filename) {
377392 script_error.text = cause.getMessage
378393 script_error.columnNum = - 1
379394 script_error.lineNum = line.getLineNumber
380395 script_error.text = thr.getMessage
381- val knimeType = Pattern .compile(" (?<=org.knime.)(.*)(?=:)" )
382- val mKnimeType = knimeType.matcher(script_error.text)
383- if (mKnimeType.find()) {
384- script_error.`type` = mKnimeType.group(1 )
385- }
386- script_error.`type` = " RuntimeError"
396+ // val knimeType = Pattern.compile("(?<=org.knime.)(.*)(?=:)")
397+ // val mKnimeType = knimeType.matcher(script_error.text)
398+ // script_error.`type` =
399+ // if (mKnimeType.find()) mKnimeType.group(1) else "RuntimeError"
400+
401+ script_error.`type` = """ (?<=org.knime.)(.*)(?=:)""" .r
402+ .findFirstMatchIn(err).map(_ group 1 ).getOrElse(" RuntimeError" )
387403 // break
388404 }
389405 }
0 commit comments