Skip to content

Commit

Permalink
Slightly better choices for exception classes
Browse files Browse the repository at this point in the history
  • Loading branch information
GreyCat committed Mar 6, 2024
1 parent 54babc4 commit c9dd0aa
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import io.kaitai.struct.datatype.DataType
import io.kaitai.struct.datatype.DataType._
import io.kaitai.struct.exprlang.Ast
import io.kaitai.struct.format.Identifier
import io.kaitai.struct.precompile.{MethodNotFoundErrorWithArg, TypeMismatchError, WrongMethodCall}
import io.kaitai.struct.precompile.{MethodNotFoundError, MethodNotFoundErrorWithArg, TypeMismatchError, WrongMethodCall}

sealed trait MethodArgType
object MethodArgType {
Expand Down Expand Up @@ -196,7 +196,7 @@ abstract trait CommonMethods[T] extends TypeDetector {
case Some(argType) =>
invokeMethod(argType, methodName.name, obj, args)
case None =>
throw new TypeMismatchError(s"don't know how to call any methods including '$methodName' on object type of '$objType'")
throw new MethodNotFoundError(methodName.name, objType)
}
}
}
Expand Down Expand Up @@ -225,8 +225,7 @@ abstract trait CommonMethods[T] extends TypeDetector {
throw new WrongMethodCall(argType, methodName, expectedArgProblems, "(" + args.mkString(", ") + ")")
}
case None =>
// TODO: potentially better error message
throw new TypeMismatchError(s"don't know how to call method '$methodName' of object type '$argType'")
throw new MethodNotFoundErrorWithArg(methodName, argType)
}
}

Expand Down

0 comments on commit c9dd0aa

Please sign in to comment.