KbException

abstract class KbException(cause: Throwable, val location: KbSourceLocation? = null, val errorCode: String = "KB-0000") : RuntimeException(source)

Base class for all kBars runtime exceptions.

Concrete subtypes:

  • KbParseException — the template source could not be parsed.

  • KbRenderException — the template parsed successfully but a fatal error occurred at render time (e.g. an unknown transform name, a malformed assign target).

Callers that want to catch all kBars exceptions should catch KbException; callers that need to distinguish parse failures from render failures should catch the concrete subtypes.

When location is non-null, it is folded into message so that even a bare stack trace identifies the offending template position rather than pointing only at kBars internals.

Parameters

cause

the underlying exception that describes the error.

location

the template position the failure is attributable to, or null when none could be determined.

errorCode

the stable conformance error code for this failure (e.g. "KB-2001"), or "KB-0000" for unclassified failures. This code is stable across kBars versions and is the portable identifier used in conformance fixture JSON files; human-readable messages are non-normative. See the kBars conformance error-code registry for the full list.

Inheritors

Constructors

Link copied to clipboard
constructor(cause: Throwable, location: KbSourceLocation? = null, errorCode: String = "KB-0000")

Properties

Link copied to clipboard
expect open val cause: Throwable?
Link copied to clipboard

the stable conformance error code for this failure (e.g. "KB-2001"), or "KB-0000" for unclassified failures.

Link copied to clipboard

the template position the failure is attributable to, or null when none could be determined.

Link copied to clipboard
override val message: String

the exception message, always non-null; includes the template position when location is non-null.