Skip to content
View as Markdown
View as Markdown

@salesforce/b2c-tooling-sdk / clients / throwOcapiError

Function: throwOcapiError()

throwOcapiError(error, response, prefix, requiredScopes?): never

Defined in: packages/b2c-tooling-sdk/src/clients/error-utils.ts:179

Throws a well-formed Error for a failed OCAPI call.

Centralizes OCAPI-terminal error handling so every call site behaves consistently:

  • OCAPI deprecation faults become an OcapiDeprecatedError with actionable SCAPI-setup guidance, naming requiredScopes when the operation has a SCAPI equivalent.
  • Everything else throws Error(${prefix}: ${message}) where message is the fault text from getApiErrorMessage.

The original error is always attached as cause for debug logging.

Parameters

error

unknown

The error object from an openapi-fetch result.

response

The HTTP response (for status fallback).

Response | { status: number; statusText: string; }

prefix

string

Operation-specific prefix, e.g. 'Failed to list code versions'.

requiredScopes?

string[]

SCAPI scope(s) the equivalent operation needs, named in the deprecation message. Omit for OCAPI-only operations.

Returns

never

Throws

Always throws — return type is never.

Released under the Apache-2.0 License.