class_docstr: Used to save a checkpoint on exception.
  
  Args:
      dirpath: directory to save the checkpoint file.
      filename: checkpoint filename. This must not include the extension.
  
  Raises:
      ValueError:
          If ``filename`` is empty.
  
  
  Example:
      >>> from lightning.pytorch import Trainer
      >>> from lightning.pytorch.callbacks import OnExceptionCheckpoint
      >>> trainer = Trainer(callbacks=[OnExceptionCheckpoint(".")])
code: def __init__(
      self, dirpath: _PATH, filename: str = "on_exception"
  ) -> None:
      super().__init__()
      if not filename:
          raise ValueError("The filename cannot be empty")
      # not optional because an exception could occur at any moment, so we cannot wait until the `setup` hook
      self.dirpath = dirpath
      self.filename = filename
  
file_path: pytorch-lightning/src/lightning/pytorch/callbacks/on_exception_checkpoint.py
imports: import os
  from typing import Any
  from typing_extensions import override
  import lightning.pytorch
  from lightning.fabric.utilities.types import _PATH
  from lightning.pytorch.callbacks import Checkpoint
label_desc: Use image node_id 1 to create a new OnExceptionCheckpoint object from inherited base classes: Checkpoint with example: obj = OnExceptionCheckpoint(dirpath, filename)