Creates a new VocabularyError instance.
Vocabulary error construction options including the
optional term and domain diagnostic fields.
Defaults: code = ERR_VOCAB_TERM_NOT_FOUND, retryable = false.
import { VocabularyError } from '#core/errors/vocabulary-error.js';
const error = new VocabularyError({
message: 'Term "vendorNum" not found in procurement domain',
attempted: 'Resolve business term: vendorNum',
term: 'vendorNum',
domain: 'procurement',
suggestions: [
'Did you mean "vendorNumber"?',
'Use getBusinessTermSuggestions() to list available terms',
],
});
ReadonlyattemptedReadonlycodeReadonlydetailsReadonlydomainReadonlyretryableReadonlyseverityReadonlysuggestionsReadonlytermReadonlytimestampReturns structured context for AI agents to reason about the vocabulary failure.
AI-friendly context object with vocabulary diagnostic fields.
Extends the base AI context with term and domain so AI agents
can suggest alternative business terms or correct domain references.
import { VocabularyError } from '#core/errors/vocabulary-error.js';
const error = new VocabularyError({
message: 'Ambiguous term matches 2 controls',
attempted: 'Resolve term: amount',
code: 'ERR_VOCAB_AMBIGUOUS_MATCH',
term: 'amount',
domain: 'sales',
});
const context = error.toAIContext();
// context.term === 'amount', context.domain === 'sales'
Serializes the error to a plain JSON-safe object.
Base serialized fields plus term and domain.
Error subclass for business vocabulary resolution failures.
Remarks
Thrown when a business vocabulary term cannot be resolved, a domain vocabulary file fails to load, or a term maps ambiguously to multiple SAP controls or actions. Includes the
termanddomainfields for diagnostic context.Sap Module
cross-module
Business Context
Business vocabulary resolution for SAP domain terms
Failure Mode
Term not found — vocabulary term has no registered definition
Failure Mode
Domain load failed — vocabulary JSON file could not be loaded
Failure Mode
Ambiguous match — term maps to multiple SAP controls or actions
Ai Context
Vocabulary term suggestions for AI — nearestTerms field provides alternatives
Example