docs/site/reference/error-codes.md
In order to allow clients to reliably detect individual error causes, LoopBack
sets the error code property to a machine-readable string.
The entity (model) was not found. This error is returned for example by
EntityCrudRepository.prototype.findById.
The data provided by the client is not a valid entity.
The value provided for a parameter of a REST endpoint is not valid. For example, a string value was provided for a numeric parameter.
No value was provided for a required parameter.
LoopBack is using TypeScript design-time type metadata to automatically infer
simple property types like string, number or a model class.
In the following example, the type of the property name is inferred from
TypeScript metadata as string.
@model()
class Product {
@property()
name: string;
}
Design-time property type is not available in the following cases:
undefinednullstring[]), generic types (Partial<MyModel>),
union types (string | number), and more.emitDecoratorMetadata.<a id="cannot_infer_property_type-solutions"></a>
You have the following options how to fix the error
CANNOT_INFER_PROPERTY_TYPE:
If you are using TypeScript, make sure emitDecoratorMetadata is enabled in
your compiler options.
{
"$schema": "http://json.schemastore.org/tsconfig",
"compilerOptions": {
"emitDecoratorMetadata": true
}
}
A typical LoopBack project is inheriting compiler options from
@loopback/build, where emitDecoratorMetadata is already enabled.
{
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "@loopback/build/config/tsconfig.common.json"
}
If your property uses a complex type, then specify the type in the type
field of @property() definition.
@model()
class UserProfile {
@property({type: 'string'})
hourFormat: '12h' | '24h';
}
Besides LoopBack-specific error codes, your application can encounter low-level
error codes from Node.js and the underlying operating system. For example, when
a connector is not able to reach the database, an error with code ECONNREFUSED
is returned.
See the following resources for a list of low-level error codes: