Skip to main content

Status

A Status represents a structured error, warning, or informational message that can be attached to a Message or used to signal stream events like retries and rollbacks.

Status codes are defined in your project's Resource Status Definition Asset, organized by Vendor. Each status has a unique code, a logical name, and a message template that supports placeholders (%1, %2, etc.).


At a Glance

// Get a vendor (defined in your Status Asset)
const VENDOR = Status.getVendorByName('MyVendor');

// Create a status with parameters
const status = Status.create(VENDOR, 'ILLEGAL_VALUE', 'LastName', 'Doe');

// Attach to a message
message.addStatus(Severity.ERROR, status);

Properties

PropertyTypeDescription
codestringStatus code identifier
messagestringResolved message (placeholders filled)
parametersstring[]Parameters passed at creation
vendorVendorThe vendor this status belongs to
vendorIdnumberVendor ID
subStatusStatus[]Child statuses
const status = Status.create(VENDOR, 'ILLEGAL_VALUE', 'LastName', 'Doe');

stream.logInfo(status.code); // "ILLEGAL_VALUE"
stream.logInfo(status.message); // "Field 'LastName' contains illegal value 'Doe'"
stream.logInfo(status.parameters); // ["LastName", "Doe"]
stream.logInfo(status.vendorId); // 42

Creating Status

create(vendor, statusCode, ...args)

Creates a Status instance from a vendor and status code. Additional arguments fill placeholder positions in the message template.

ParameterTypeDescription
vendorVendorVendor instance
statusCodestringLogical name of the status (e.g., 'ILLEGAL_VALUE')
...argsstringValues for %1, %2, etc. placeholders

Returns: Status

const VENDOR = Status.getVendorByName('MyVendor');

// Status template: "Field '%1' contains illegal value '%2'."
const status = Status.create(VENDOR, 'ILLEGAL_VALUE', 'LastName', 'Doe');
// Resolved message: "Field 'LastName' contains illegal value 'Doe'."

// Single parameter
const status2 = Status.create(VENDOR, 'FIELD_REQUIRED', 'Email');
// Resolved message: "Field 'Email' is required."

// No parameters
const status3 = Status.create(VENDOR, 'UNKNOWN_ERROR');

Finding Vendors

Status codes are organized by vendor. You must obtain a vendor reference before creating statuses.

MethodDescription
getVendorByName(longName)Find by long name
getVendorByShortName(shortName)Find by short name
getVendorById(id)Find by numeric ID
// By long name (most common)
const VENDOR = Status.getVendorByName('MyApplication');

// By short name
const VENDOR = Status.getVendorByShortName('MYAPP');

// By ID (1 is reserved for internal "LAY" vendor)
const VENDOR = Status.getVendorById(2);

Accessing Status Details

MethodReturnsDescription
getCode()stringStatus code
getMessage()stringRaw message template (placeholders not filled)
getParameters()string[]Creation parameters
getVendor()VendorVendor instance
getVendorId()numberVendor ID
getSubStatus()Status[]Child statuses
const status = Status.create(VENDOR, 'ILLEGAL_VALUE', 'LastName', 'Doe');

status.getCode(); // "ILLEGAL_VALUE"
status.getMessage(); // "Field '%1' contains illegal value '%2'." (raw template)
status.getParameters(); // ["LastName", "Doe"]
Property vs Getter

status.message returns the resolved message (placeholders filled).
status.getMessage() returns the raw template (placeholders as %1, %2).


Complete Example

const VENDOR = Status.getVendorByName('OrderValidation');

export function onMessage() {
// Validate quantity
const qty = message.getInt(dataDictionary.type.Order.QUANTITY);
if (qty <= 0) {
const status = Status.create(VENDOR, 'INVALID_QUANTITY', qty.toString());
message.addStatus(Severity.ERROR, status);
}

// Validate email format
const email = message.getString(dataDictionary.type.Order.EMAIL);
if (!email || !email.includes('@')) {
const status = Status.create(VENDOR, 'INVALID_EMAIL', email);
message.addStatus(Severity.ERROR, status);
}

// Check for errors before emitting
if (message.hasStatusAttached(Severity.ERROR)) {
stream.emit(message, ERROR_PORT);
} else {
stream.emit(message, OUTPUT_PORT);
}
}

See Also