ClassNotFoundException constructor

ClassNotFoundException(
  1. String className, {
  2. String? message,
})

A runtime exception in Jetleaf thrown when a requested class cannot be found by the runtime provider.

This exception indicates a class resolution failure during runtime reflection or materialization.


Common Causes

This typically occurs when:

  • The class has not been registered or scanned by the runtime provider
  • There is a typo in the requested class name or qualified name
  • The class is missing from the active package or library context

Usage Example

try {
  final clazz = Class.forName('NonExistentClass');
} on ClassNotFoundException catch (e) {
  print(e);
}

This exception is the base class for more specific class resolution failures such as ImmaterialClassException.

Implementation

ClassNotFoundException(this.className, {String? message}) : super(message ??
  'Class "$className" could not be found.\n'
      'This typically means:\n'
      ' • The class has not been registered with the runtime provider.\n'
      ' • A typo exists in the requested class name.\n'
      ' • The class is missing from the current ClassLoader context.\n',
);