Skip to content

Error codes ​

A refused submission returns a stable error code. The SDK throws it as a CanardFormError with error, status and errors (details per field).

js
import { CanardFormError, submitForm } from '@canardform/sdk';

try {
  await submitForm('ID', { email: 'jane@example.com' });
} catch (error) {
  if (error instanceof CanardFormError && error.error === 'validation_failed') {
    console.log(error.errors); // { 'answers.email': ['…'] }
  }
}
CodeMeaning
validation_failedan answer is invalid, details in errors
form_closedthe form is suspended, archived or outside its dates; see Closed or unavailable form
rate_limitedtoo many submissions from the same connection
captcha_failedthe hCaptcha token is missing, invalid or already used
quota_exceededthe organization's monthly answer quota is reached
storage_quota_exceededthe file storage space is full
origin_not_allowedthis website is not in the form's allowed websites; add it in the form settings. localhost is not allowed by default: add it too for local tests
spam_rejectedthe bot trap was filled
idempotency_conflictsame idempotency key, different content
idempotency_in_progressthe same submission is already in progress
not_foundgetForm could not read the form (unknown, unpublished, server error)
http_erroran error response without a code

A network failure (server unreachable, offline visitor) throws the browser's own error (TypeError), not a CanardFormError. fieldErrors(error.errors) gives the first message of each refused field, by key.

Released under the MIT License.