Errors

Errors

Source:

This is the only file that is permitted to create new Error objects. Any throw that occurs in this library will be one of the errors listed.

As such, any try/catch code you write against this library should make sure to not blind-catch, but catch intentionally:


  import { Errors } from "use-models-for-data";
  import { MyModel } from "./my-models.js";

  try {
    MyModel.load(`someRecordName`);
  } catch (err) {
    const type = err.__proto__.constructor;
    switch(type) {
      case (Errors.RecordDoesNotExist): ...
      case (Errors.RecordAccessError): ...
      ...
      case (TypeError): ...
      default: throw err;
    }
  }

Members

(static) AssignmentMustBeArray

Source:
Used in Models to signal that an assignment to an array property was not an array.

(static) BadModelDataSubmission

Source:
Used in Model to signal that a data update using a form submission object did not succeed due to validation failure.

(static) CouldNotFindModel

Source:
Used in the ModelRegistry to signal that the code tried to access an unknown schema.

(static) DoNotUseModelConstructor

Source:
Thrown when code tries to construct a model using the new keyword, rather than the create() function.

(static) FieldFailedCustomValidation

Source:
Used in the model field code to signal that a value did not pass custom validation (even if it passed basic validation).

(static) IncompleteModelSave

Source:
Used in Model to signal that the user tried to save a model that is missing required values (something which can only be the case if the model was built using the ALLOW_INCOMPLETE symbol)

(static) IncorrectSyncType

Source:
Thrown by anything that intends to be an abstract superclass, to make sure subclasses implement the necessary methods.

(static) InvalidAssignment

Source:
Used in {@Models} to signal that a property assignment was not permitted according to the model schema.

(static) MissingChoicesArray

Source:
Used in the model fields code to signal that an expected choices array is missing from the field properties.

(static) MissingCreateFunction

Source:
Used by the form building code to warn the user that they forgot to provide a create() function for transforming tag/props tuples into nodes.

(static) MissingImplementation

Source:
Thrown by anything that intends to be an abstract superclass, to make sure subclasses implement the necessary methods.

(static) MissingRecordNameBinding

Source:
Used by the schema code to signal that a model could not be saved using an unqualified save() call.

(static) ModelCreateWithBadData

Source:
Used in Model to signal that .create(data) was passed non-object data

(static) ModelFormDeclarationHasUnknownFields

Source:
Used in the model registration process when a model with __meta.form code refers to fields that do not exist on the model.

(static) ModelFromMissingData

Source:
Used in Model to signal that .from(data) was called without a data payload.

(static) NoStoreFound

Source:
Used in the Models code when a code path assumes that there is a store available when there isn't.

(static) NothingToMigrate

Source:
Used in migration code to signal that there are no actual diffs to migrate, despite being in a codepath that assumes that there are.

(static) PropertySchemaViolation

Source:
Used in schema validation code, specifically the array wrapper, to signal an illegal value assignment.

(static) RecordAccessError

Source:
Used to signal that a backend can find a record, but can't access it.

(static) RecordDoesNotExist

Source:
Used to signal a record cannot be resolved by a backend

(static) RecordParseError

Source:
Used to signal a filepath resolves to a file, but its content could not be parse as model record data.

(static) RequiredFieldsMissing

Source:
Used in Models to signal that something tried to build a Model without specifying values for all required properties in that model.

(static) SchemaMismatchForModel

Source:
Used in the ModelRegistry to signal that the currently loaded version of a schema does not match the stored version of that same schema.

(static) StoreNotReady

Source:
Used in the Models code when a code path assumes that a store is ready for use when it isn't.

(static) TypeNotMatchedToChoices

Source:
Used in the model fields code when a choice field with a default value does not contain that value in the available choices.

(static) UndefinedKey

Source:
Used in Model to signal a missing object property that was expect to exist, based on the model schema.