Constructs a new InvalidInstanceOfError
with the specified key and
expected instance type.
The name of the key with the invalid instance.
The expected class or constructor name.
Optional
causeOptional
stackStatic
Optional
prepareOptional override for formatting stack traces
Static
stack
The
InvalidInstanceOfError
is thrown when a value associated with a key is not an instance of the expected class or constructor.This error is useful when checking for object instances (e.g.,
Date
,File
) and enforcing that the value matches the expected class.Example