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
Used in Models to signal that an assignment to an
array
property was not an array.
(static) BadModelDataSubmission
Used in Model to signal that a data update using a form submission object did not succeed due to validation failure.
(static) CouldNotFindModel
Used in the ModelRegistry to signal that the code tried to access an unknown schema.
(static) DoNotUseModelConstructor
Thrown when code tries to construct a model using the
new
keyword, rather than the create()
function.
(static) FieldFailedCustomValidation
Used in the model field code to signal that a value did not pass custom validation (even if it passed basic validation).
(static) IncompleteModelSave
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
Thrown by anything that intends to be an abstract superclass, to make sure subclasses implement the necessary methods.
(static) InvalidAssignment
Used in {@Models} to signal that a property assignment was not permitted according to the model schema.
(static) MissingChoicesArray
Used in the model fields code to signal that an expected
choices
array is missing from the field properties.
(static) MissingCreateFunction
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
Thrown by anything that intends to be an abstract superclass, to make sure subclasses implement the necessary methods.
(static) MissingRecordNameBinding
Used by the schema code to signal that a model could not be saved using an unqualified
save()
call.
(static) ModelCreateWithBadData
Used in Model to signal that .create(data) was passed non-object data
(static) ModelFormDeclarationHasUnknownFields
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
Used in Model to signal that .from(data) was called without a data payload.
(static) NoStoreFound
Used in the Models code when a code path assumes that there is a store available when there isn't.
(static) NothingToMigrate
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
Used in schema validation code, specifically the array wrapper, to signal an illegal value assignment.
(static) RecordAccessError
Used to signal that a backend can find a record, but can't access it.
(static) RecordDoesNotExist
Used to signal a record cannot be resolved by a backend
(static) RecordParseError
Used to signal a filepath resolves to a file, but its content could not be parse as model record data.
(static) RequiredFieldsMissing
Used in Models to signal that something tried to build a Model without specifying values for all
required
properties in that model.
(static) SchemaMismatchForModel
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
Used in the Models code when a code path assumes that a store is ready for use when it isn't.
(static) TypeNotMatchedToChoices
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
Used in Model to signal a missing object property that was expect to exist, based on the model schema.