Skip to content

Commit

Permalink
fix: Return fatal error in operations
Browse files Browse the repository at this point in the history
Adjust all operations to return a fatal error instead of returning null. This is required to limit the access to the special input symbol `?` outside an unary-tests.

Restructure some helper methods to restrict the handling of fatal errors to a few places. This should help to reduce possible problems with fatal errors.

Move some methods to group different aspects together.
  • Loading branch information
saig0 committed Aug 20, 2024
1 parent 61cb169 commit c967208
Show file tree
Hide file tree
Showing 2 changed files with 351 additions and 423 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.camunda.feel.impl.builtin

import org.camunda.feel.logger
import org.camunda.feel.syntaxtree.{Val, ValError, ValFunction, ValNull}
import org.camunda.feel.syntaxtree.{Val, ValError, ValFatalError, ValFunction, ValNull}

object BuiltinFunction {

Expand All @@ -34,9 +34,10 @@ object BuiltinFunction {
}

private def error: PartialFunction[List[Val], Any] = {
case args if (args.exists(_.isInstanceOf[ValError])) =>
args.filter(_.isInstanceOf[ValError]).head.asInstanceOf[ValError]
case args =>
case args if args.exists(_.isInstanceOf[ValFatalError]) =>
args.find(_.isInstanceOf[ValFatalError])
case args if args.exists(_.isInstanceOf[ValError]) => args.find(_.isInstanceOf[ValError])
case args =>
val argumentList = args.map("'" + _ + "'").mkString(", ")
ValError(s"Illegal arguments: $argumentList")
}
Expand Down
Loading

0 comments on commit c967208

Please sign in to comment.