@@ -83,7 +83,7 @@ class RubyScriptNodeModel (
8383 class ScriptError {
8484 var lineNum : Int = - 1
8585 var columnNum : Int = - 1
86- var `type` : String = " --UnKnown--"
86+ var errType : String = " --UnKnown--"
8787 var text : String = " --UnKnown--"
8888 var trace : String = " "
8989 var msg : String = " "
@@ -258,18 +258,14 @@ end
258258 container.setError(new LoggerOutputStream (logger, NodeLogger .LEVEL .ERROR ))
259259 container.put(" $num_inputs" , numInputs)
260260 container.put(" $input_datatable_arr" , inData)
261- i = 0
262- while (i < numInputs) {
261+ for (i <- 0 until numInputs) {
263262 container.put(" $inData%d" .format(i), inData(i))
264263 container.put(" $in_data_%d" .format(i), inData(i))
265- i += 1
266264 }
267265 container.put(" $output_datatable_arr" , outContainer)
268- i = 0
269- while (i < numOutputs) {
266+ for (i <- 0 until numOutputs) {
270267 container.put(" $outContainer%d" .format(i), outContainer(i))
271268 container.put(" $out_data_%d" .format(i), outContainer(i))
272- i += 1
273269 }
274270 container.put(" $outContainer" , outContainer(0 ))
275271 container.put(" $outColumnNames" , columnNames)
341337 val newColumn = new DataColumnSpecCreator (columnNames(i), newColumnType).createSpec()
342338 newSpec = AppendedColumnTable .getTableSpec(newSpec, newColumn)
343339 }
344- if (script == null ) {
345- script = " "
346- }
347- val result = Array .ofDim[DataTableSpec ](numOutputs)
348- for (i <- 0 until numOutputs) {
349- result(i) = newSpec
350- }
351- result
340+
341+ val result = for (i <- 0 until numOutputs) yield { newSpec }
342+ result.toArray
352343 }
353344
354345 protected override def loadInternals (nodeInternDir : File , exec : ExecutionMonitor ) {
399390 logger.debug(" SyntaxError: " + script_error.text)
400391 script_error.lineNum = line.toInt
401392 script_error.columnNum = - 1
402- script_error.`type` = " SyntaxError"
393+ script_error.errType = " SyntaxError"
394+ case _ =>
403395 }
404396
405397 } else {
@@ -408,24 +400,26 @@ end
408400// if (mLine.find()) {
409401// script_error.`type` = mLine.group(1)
410402// }
411- script_error.`type` = """ (?<=\()(\w*)""" .r
412- .findFirstMatchIn(err).map(_ group 2 ).getOrElse(script_error.`type` )
403+ script_error.errType = """ (?<=\()(\w*)""" .r
404+ .findFirstMatchIn(err).map(_ group 2 ).getOrElse(script_error.errType )
413405
414406 val cause = thr.getCause
415- for (line <- cause.getStackTrace if line.getFileName == filename) {
416- script_error.text = cause.getMessage
417- script_error.columnNum = - 1
418- script_error.lineNum = line.getLineNumber
419- script_error.text = thr.getMessage
420- // val knimeType = Pattern.compile("(?<=org.knime.)(.*)(?=:)")
421- // val mKnimeType = knimeType.matcher(script_error.text)
422- // script_error.`type` =
423- // if (mKnimeType.find()) mKnimeType.group(1) else "RuntimeError"
424-
425- script_error.`type` = """ (?<=org.knime.)(.*)(?=:)""" .r
426- .findFirstMatchIn(err).map(_ group 1 ).getOrElse(" RuntimeError" )
427- // break
428- }
407+ cause.getStackTrace
408+ .filter(line => line.getFileName == filename)
409+ .map(line => {
410+ script_error.text = cause.getMessage
411+ script_error.columnNum = - 1
412+ script_error.lineNum = line.getLineNumber
413+ script_error.text = thr.getMessage
414+ // val knimeType = Pattern.compile("(?<=org.knime.)(.*)(?=:)")
415+ // val mKnimeType = knimeType.matcher(script_error.text)
416+ // script_error.`type` =
417+ // if (mKnimeType.find()) mKnimeType.group(1) else "RuntimeError"
418+
419+ script_error.errType = """ (?<=org.knime.)(.*)(?=:)""" .r
420+ .findFirstMatchIn(err).map(_ group 1 ).getOrElse(" RuntimeError" )
421+ // break
422+ }).head
429423 }
430424 script_error.msg = " script" + (script_error.lineNum match {
431425 case - 1 => " ] stopped with error at line --unknown--"
442436// } else {
443437// script_error.msg += "] stopped with error at line --unknown--"
444438// }
445- if (script_error.`type` == " RuntimeError" ) {
446- logger.error(script_error.msg + " \n " + script_error.`type` + " ( " + script_error.text + " )" )
439+ if (script_error.errType == " RuntimeError" ) {
440+ logger.error(script_error.msg + " \n " + script_error.errType + " ( " + script_error.text + " )" )
447441 val cause = thr.getCause
448442 val stack = cause.getStackTrace
449443 val builder = new StringBuilder ()
465459 script_error.trace +
466460 " --- Traceback --- end --------------" )
467461 }
468- } else if (script_error.`type` != " SyntaxError" ) {
462+ } else if (script_error.errType != " SyntaxError" ) {
469463 logger.error(script_error.msg)
470464 logger.error(" Could not evaluate error source nor reason. Analyze StackTrace!" )
471465 logger.error(err)
0 commit comments