Class ConfigParseException

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    ConfigVetoedException, OwnLogCarryingMissingFileException

    public class ConfigParseException
    extends java.lang.Exception
    A failure to parse configuration, carrying the report of that failure with it.

    Whoever throws one of these owes it a complete account of what went wrong. That is the whole point of the class, and it is an obligation rather than a convenience, because nobody logs anything on its behalf: a caller that catches a ConfigParseException drains getDelayedLogItems() and does no more. Throw one carrying an empty list and the failure passes in total silence.

    The reason the items have to travel on the exception is that there is no other way out. A PropertiesConfigSource reports through the PropertiesConfigSource.Parse it returns, and a Parse is only ever constructed on the success path — so everything a source accumulated before it threw is discarded at the throw. Sources cannot simply log instead: they run while MLog is still reading its own configuration, which is why DelayedLogItem exists at all.

    So the rule for an implementor is: before throwing, put into the list every item you would have returned on the Parse, plus an item describing the failure itself. Pass the list you have been accumulating into; it is copied, not retained.

    See Also:
    OwnLogCarryingMissingFileException, Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ConfigParseException​(java.lang.String msg, java.lang.Throwable cause, java.util.List<DelayedLogItem> delayedLogItems)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<DelayedLogItem> getDelayedLogItems()
      The report this exception carries.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ConfigParseException

        public ConfigParseException​(java.lang.String msg,
                                    java.lang.Throwable cause,
                                    java.util.List<DelayedLogItem> delayedLogItems)
    • Method Detail

      • getDelayedLogItems

        public java.util.List<DelayedLogItem> getDelayedLogItems()
        The report this exception carries. Never null.

        A caller that swallows this exception must drain this list, or the account the thrower prepared is never made and the failure goes unmentioned.