rootCause property

Object? get rootCause

The innermost cause: cause followed through nested container errors, or null without a cause. Usually the error that really went wrong. Spring: getRootCause().

} on BeanCreationException catch (e) {
  log.error(e.rootCause); // e.g. the StateError a constructor threw
}

Implementation

Object? get rootCause {
  Object? root;
  for (var current = cause; current != null;) {
    root = current;
    current = current is BeansException ? current.cause : null;
  }
  return root;
}