Skip to content

SparkConnectError

Defined in: errors.ts:83

An error returned by the Spark Connect server or raised at the gRPC transport layer.

Carries the gRPC code, and when available the Spark errorClass (for example "TABLE_OR_VIEW_NOT_FOUND") and SQL state code.

.message already includes the [errorClass] prefix when the class is known. Print it verbatim instead of re-prefixing.

try {
await spark.sql("SELECT * FROM missing").collect();
} catch (err) {
if (err instanceof SparkConnectError && err.errorClass === "TABLE_OR_VIEW_NOT_FOUND") {
// handle known error class
}
}
  • Error
new SparkConnectError(message, options): SparkConnectError;

Defined in: errors.ts:111

Parameter Type
message string
options { cause?: unknown; code: number; errorClass?: string; errorTypeHierarchy?: readonly string[]; messageParameters?: Record<string, string>; serverStackTrace?: readonly string[]; sqlState?: string; }
options.cause? unknown
options.code number
options.errorClass? string
options.errorTypeHierarchy? readonly string[]
options.messageParameters? Record<string, string>
options.serverStackTrace? readonly string[]
options.sqlState? string

SparkConnectError

Error.constructor
readonly code: number;

Defined in: errors.ts:85

gRPC status code (0 = OK, 14 = UNAVAILABLE, etc.)


readonly optional errorClass?: string;

Defined in: errors.ts:88

Spark error class if available (e.g. “TABLE_OR_VIEW_NOT_FOUND”)


readonly optional errorTypeHierarchy?: readonly string[];

Defined in: errors.ts:101

Fully qualified class names of the server-side exception and its parent classes, root-most first. Populated when the server returns rich error details via FetchErrorDetails.


readonly optional messageParameters?: Record<string, string>;

Defined in: errors.ts:94

Server-supplied error message parameters keyed by name.


readonly optional serverStackTrace?: readonly string[];

Defined in: errors.ts:109

Server-side stack trace as JVM frame strings, populated only when the server has spark.sql.connect.serverStacktrace.enabled=true. Production deployments usually leave this disabled, so the field is empty in most cases.


readonly optional sqlState?: string;

Defined in: errors.ts:91

SQL state code if available (e.g. “42P01”)