Skip to content

Diagnostics ​

Three types, one option. See the guide for usage and for reading the symptoms.

DegradationHandler ​

ts
type DegradationHandler = (event: DegradationEvent) => void;

Passed through RenderOptions.onDegradation — accepted by renderPackageToHtml, renderDocumentToHtml, renderSpecification, createAttachmentLookup and renderXhtmlContent.

An exception thrown inside the handler is caught and ignored. A diagnostic channel that broke what it was observing would be worse than no channel at all.

DegradationEvent ​

ts
interface DegradationEvent {
  code: DegradationCode;
  /** A readable sentence, safe to log as-is. */
  message: string;
  /** What identifies the place: an id, a path, a tag name, the offending value. */
  detail?: Record<string, unknown>;
}

DegradationCode ​

ts
type DegradationCode =
  | "attachment-missing"
  | "attachment-too-large"
  | "unresolved-reference"
  | "orphan-attribute-value"
  | "missing-spec-object"
  | "duplicate-dom-id"
  | "custom-renderer-threw"
  | "custom-renderer-unbalanced-html"
  | "custom-renderer-raw-string"
  | "custom-renderer-dropped-attr"
  | "dropped-tag"
  | "unwrapped-tag"
  | "dropped-style-declaration"
  | "dropped-href"
  | "unparsable-date"
  | "invalid-locale";
CodeSituationdetail keys
attachment-missinga referenced attachment no resolver can findpath
attachment-too-largean attachment over maxInlineBytes, left unresolvedpath, size, maxInlineBytes
unresolved-referencea SpecRelation pointing at an object absent from the renderrelation, sourceRef, targetRef
orphan-attribute-valuea value whose AttributeDefinition is absent from the declared SpecTypespecObject, definitionRef, specType
missing-spec-objecta tree node pointing at a SpecObject that does not existspecHierarchy, objectRef
duplicate-dom-idan object rendered more than once; only the first carries the idspecObject, id, specHierarchy
custom-renderer-threwa customAttributeRenderers threw and was ignoredattribute, specObject, error
custom-renderer-unbalanced-htmldangerouslyRawHtml left unbalanced, escaped as textattribute, specObject, html
custom-renderer-raw-stringa renderer returned a bare string; escaped as textattribute, specObject, value
custom-renderer-dropped-attra node carried an attribute outside the allowlistattribute, specObject, attr, tag
dropped-taga tag removed along with its subtree (<script>, <iframe>…)tag
unwrapped-taga non-allow-listed tag unwrapped, children kepttag
dropped-style-declarationan invalid style declaration discardedprop, value
dropped-hrefa javascript: / vbscript: / data: href neutralisedhref
unparsable-datea date that could not be parsed, shown as-isvalue
invalid-localeIntl rejected the configured localelocale, value

The identifiers reported (specObject, specHierarchy, relation…) are ReqIF identifiers, not DOM ids — except the id key of duplicate-dom-id, which is indeed the conflicting HTML anchor.

Volume

dropped-tag and unwrapped-tag can fire thousands of times on a large export — every disallowed Word formatting <span> counts. This is a diagnostic channel, not a production log: filter by code, or only turn the option on while investigating.

The rendering does not change

Wiring up a handler changes strictly nothing about the HTML output. The option makes decisions that were already taken visible; it takes none of its own.

Released under the MIT licence. Conformant to OMG ReqIF v1.2 (formal/2016-07-01).