SDK for Node.js

Errors

Every failure is a SecureCloudError with a code you can check and a message that says what to do next.

server.js
const { isSecureCloudError } = require("@secure-cloud/sdk");

try {
  await cloud.files.get(fileId);
} catch (error) {
  if (isSecureCloudError(error) && error.code === "NOT_FOUND") {
    return res.status(404).send("No such file");
  }
  throw error; // anything else: let errorHandler() deal with it
}
NameTypeWhat it is
codestringA stable name, like NOT_FOUND. Check this, not the message.
statusnumberThe HTTP status, or 0 when the platform couldn't be reached.
messagestringWhat went wrong, in plain words.
requestIdstring (optional)Search for it in your workspace's audit log to see what happened.

Setup problems

NameTypeWhat it is
MISSING_API_KEY0No key: set SECURE_CLOUD_API_KEY, or pass { apiKey }.
INVALID_URL0SECURE_CLOUD_URL isn't an address like http://localhost:8080.
UNREACHABLE0The gateway didn't answer at that address. Is it running?
TIMEOUT0No answer within 30 seconds (change it with { timeoutMs }).
INVALID_API_KEY401The API key is wrong or revoked. Create a new one in the dashboard.
INVALID_POOL_ID0userPool() got something that isn't a pool ID.

Common answers

NameTypeWhat it is
BAD_REQUEST400Something you sent isn't valid; the message says what.
UNAUTHORIZED401From signIn(): a wrong email or password.
INVALID_TOKEN401From verify(): the token is expired, forged or for another pool.
FORBIDDEN403Your workspace is suspended, or a limit refused the call. From requireRole() or requirePermission(): the user lacks the role or permission.
NOT_FOUND404No such file, connection or user in your workspace.
CONFLICT409Already exists, like a taken email.
PAYLOAD_TOO_LARGE413The file is too big.
RATE_LIMITED429Too many requests; slow down and try again.
SECRETS_SEALED503The vault is sealed until it is unsealed. Try again later.
SERVICE_UNAVAILABLE503A part of the platform is down for a moment.