# MessageSourceException class

An exception that occurs when resolving messages from a `MessageSource`.

This exception provides additional context beyond a simple error message:

- code: the message key that failed to resolve.
- locale: the locale that was requested when the error occurred.
- resource: the underlying resource (e.g., file, bundle, or database) involved.
- cause: the original exception that triggered this error, if any.

This is especially useful in internationalization (i18n) and configuration systems where message lookup may fail due to missing keys, unsupported locales, or inaccessible resources.

### Example

    void loadMessage(String key, Locale locale) {
      throw MessageSourceException(
        "Message key not found",
        code: key,
        locale: locale,
        resource: "messages_en.properties",
      );
    }

    try {
      loadMessage("missing.key", Locale("en"));
    } catch (e) {
      print(e);
      // Output:
      // MessageSourceException: Message key not found [code=missing.key] [locale=en] [resource=messages_en.properties]
    }

Inheritance
  - Object
  - Error
  - RuntimeException
  - MessageSourceException
Available extensions
  - ErrorExtensions
  - ExceptionExtensions
  - RuntimeExceptionExtensions
  - ThrowableExtensions

## Constructors

MessageSourceException.new(String message, {String? code, Locale? locale, String? resource, Object? cause})
  An exception that occurs when resolving messages from a `MessageSource`.

## Properties

cause → Object?
  The underlying cause of this exception, if any.
  final inherited
code → String?
  The message code (key) that failed to resolve.
  final
hashCode → int
  The hash code for this object.
  no setter inherited
locale → Locale?
  The locale in which the message was being resolved.
  final
message → String
  The message describing the error.
  final inherited
resource → String?
  The resource (e.g., properties file, database, etc.) that was queried during resolution.
  final
runtimeType → Type
  A representation of the runtime type of the object.
  no setter inherited
stackTrace → StackTrace
  The associated stack trace.
  final inherited

## Methods

getCause() → Object
  The cause of this exception, if any.
  inherited
getMessage() → String
  The message associated with this exception.
  inherited
getStackTrace() → StackTrace
  The stack trace associated with this exception.
  inherited
noSuchMethod(Invocation invocation) → dynamic
  Invoked when a nonexistent method or property is accessed.
  inherited
printStackTrace([bool useErrorPrint = false]) → void

  Available on Error, provided by the ErrorExtensions extension

  Prints the error along with its stack trace.
printStackTrace([StackTrace? stacktrace, bool useErrorPrint = false]) → void

  Available on Exception, provided by the ExceptionExtensions extension

  Prints the exception and optional StackTrace if available.
printStackTrace([bool useErrorPrint = false]) → void

  Available on RuntimeException, provided by the RuntimeExceptionExtensions extension

  Extension on RuntimeException to support pretty stack trace printing.
printStackTrace([bool useErrorPrint = false]) → void

  Available on Throwable, provided by the ThrowableExtensions extension

  Extension on Throwable to support printing stack traces in a unified way.
toString() → String
  A string representation of this object.
  override

## Operators

operator ==(Object other) → bool
  The equality operator.
  inherited