UserError extends Error

This is an extension of the standard JavaScript Error object.

It should be used for errors that were caused by user actions or user data, that the user should be able to correct.

This is contrast to AppError which indicates an application-level error that represents an internal error within the application code.

UserError is also used to contain validation errors when doing form validation.

See Exceptions for more information.

constructor

(opts: object | string)

If opts is a string, then it contains the message description of the problem. The technical will default to being undefined.

If opts is an objec†, then:

{
  message: string;       // This message contains an end-user-facing error message that can be displayed in the UI.
  technical?: string;    // If present, this should contain additional technical information that would be relevant to a software developer.
  field?: Field;         // This indicates an error is directly related to a given field.
  lineNumber?: number;   // This indicates any line number that has to do with the error message.
  rowNumber?: number;    // This indicates any row number that has to do with the error message.
  columnNumber?: number; // This indicates any column number that has to do with the error message.
}

instance

columnNumber?: number

This indicates any column number that has to do with the error message. For UserErrors this could refer to a column in a UI table or a multi-line form field, for example so that client-code can better identify the source of the error to the user.

field?: Field

This indicates an error is directly related to a given field.

lineNumber?: number

This indicates any line number that has to do with the error message.

message: string

This message contains an end-user-facing error message that can be displayed in the UI.

rowNumber?: number

This indicates any row number that has to do with the error message. For UserErrors this could refer to a row in a UI table or a multi-line form field, for example so that client-code can better identify the source of the error to the user.

stack?: string

This contains the stack trace if available.

technical?: string

If present, this should contain additional technical information that would be relevant to a software developer.

toPlain(): object

This returns a "Plain old JavaScript object" representation of this exception that is suitable for stringifying to JSON.

toString(): string

This returns message.