kernel/EXCEPTION_PRINCIPLES.md
Exceptions thrown in Delta Kernel are either user-facing or developer-facing.
See User-facing vs developer-facing exceptions for examples of these types of exceptions.
These are the general exception principles to follow and enforce when contributing code or reviewing pull requests.
KernelException.
TableNotFoundException) otherwise just use KernelException. Subclasses should expose useful exception parameters on a case-by-case basis.KernelExceptions should be instantiated with a method in the DeltaErrors file.Engine implementation should be wrapped with KernelEngineException and should include additional context about the failing operation.
Engine implementation should be wrapped. See Wrapping exceptions thrown from the Engine implementation for more details.User-facing exceptions:
TableNotFoundException when there is no Delta table at the provided path.Developer-facing exceptions:
getInt is called on a boolean ColumnVector.Engine implementation when reading files.We want to wrap any unchecked exceptions thrown from the Engine implementation with KernelEngineException and include additional context about the failing operation. This makes it clear where the exception is originating from, and the additional context can help future debugging.
This requires wrapping all method calls into the Engine implementation. We do this using helper methods in DeltaErrors like wrapEngineException. For usage see example 1 and example 2.
Note: this does not catch all exceptions originating from the engine implementation, as exceptions that are not thrown until access will not be wrapped (i.e. exceptions thrown within iterators, in ColumnVector implementations, etc)
KernelEngineException. See here for an example.