Generate experiences with Puck AI
Read docs
CloudAPI referencecloud-clientTypesPuckCloudError

PuckCloudError

Thrown by puckCloud() methods when Puck Cloud refuses or fails a request.

import { PuckCloudError } from "@puckeditor/cloud-client";
 
try {
  await puck.pages.create({ path: "/about" });
} catch (error) {
  if (error instanceof PuckCloudError && error.statusCode === 400) {
    // The path is invalid, or another page has it
  }
}

Params

ParamExampleTypeStatus
statusCodestatusCode: 404NumberRequired
messagemessage: "Puck 404 (Not Found): Page not found"StringRequired
rawraw: { status: 404, error: "Page not found" }Object | nullRequired

statusCode

The HTTP status of the response from Puck Cloud, for example 404 for a missing page.

message

What went wrong, with the reason Puck Cloud gave.

raw

The JSON body of the response, or null if the response has no JSON body.