RoutineRaiseException

class RoutineRaiseException(sqlState: String, serverErrorMessage: ServerErrorMessage) : OctaviusException

Exception thrown when a PL/pgSQL routine raises an error of its own, through RAISE EXCEPTION.

This is the database saying no on purpose: a business rule expressed where the data is, rather than a routine that turned out to be broken. Those are RoutineAssertionException and are a separate type precisely so the two can be handled apart.

There is no reason enum here because there is nothing to tell apart. A plain RAISE EXCEPTION reports P0001; P0000 is reachable only by asking for it - RAISE ... USING ERRCODE = 'plpgsql_error' - so it is another deliberate raise rather than an unclassified failure. Which one it was is sqlState, and what it was about is dbMessage.

RAISE EXCEPTION ... USING ERRCODE reaching further than P0, on the other hand, leaves this class entirely: ERRCODE = '23505' is routed by the code it names and arrives as a ConstraintViolationException.

Parameters

sqlState

The SQL state code returned by the database.

serverErrorMessage

The original error message from the database server.

Constructors

Link copied to clipboard
constructor(sqlState: String, serverErrorMessage: ServerErrorMessage)

Properties

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

Explicit DETAIL field provided by PostgreSQL.

Link copied to clipboard

The primary error message the routine raised (the PostgreSQL MESSAGE field).

Link copied to clipboard
val hint: String?

Explicit HINT field provided by PostgreSQL.

Link copied to clipboard
open val message: String?
Link copied to clipboard

The context of the query that resulted in this exception, if applicable.

Link copied to clipboard

The raw error message received from the database, if applicable.

Link copied to clipboard

The SQL state code associated with the error, if applicable.

Link copied to clipboard

Call stack or context (WHERE field) of the PL/pgSQL execution.

Functions

Link copied to clipboard

Finds the Octavius failure behind this throwable, if there is one.

Link copied to clipboard
open override fun getDetailedMessage(): String

Provides a detailed, human-readable description of the error.

Link copied to clipboard
open override fun toString(): String