Skip to main content
Every failure Inkkit reports is an InkKitError. Branch on its code; the message is for logs. A failed call changes nothing, except after internal.

InkKitError

EditorErrorCode is the closed list of codes in error codes. When a failure started outside Inkkit, such as in an adapter, the host clipboard handler or the diagram renderer, the original error is cause. There is no separate source field: the code and cause say where a failure came from. You can construct an InkKitError yourself, for example in a test double.

How errors arrive

  • Synchronous members throw; asynchronous members reject. mount, printableSnapshot, clipboardSnapshot, paste and destroy never throw, and destroy never rejects. A thrown or rejected InkKitError means the call changed nothing and sent no changed or commandStateChanged event for it. See state checks for which member checks what, and in which order.
  • A failure goes to the caller and nowhere else. When the preservation check refuses an edit that a call such as insertText, format or paste makes, that call throws or rejects with preservation, and events.error isn’t called.
  • events.error receives failures that no call is waiting for, such as an edit the person makes or a file that fails to resolve. See failures without a caller.
  • Results describe partial outcomes. false means a call didn’t apply. Degraded clipboard and print output describes itself in warnings and isn’t also reported as an error.
  • Exceptions from your own handlers stay yours. When changed, commandStateChanged, openLink, copy or error throws, Inkkit passes the exception to the platform’s reportError() and carries on. It never becomes an InkKitError and never makes a call fail. A clipboard handler that throws or rejects is reported as clipboard-unavailable.
Any error except destroyed and internal leaves the editor usable.

Error codes

Failures without a caller

events.error receives these failures, each as an InkKitError. Without an error handler they are dropped.

Warnings

Degraded output describes itself instead of failing. PrintableDocument.warnings holds PrintableWarning values, each with a code and a message; their codes are separate from EditorErrorCode. In ClipboardOutput, an image or diagram whose picture couldn’t be produced carries error. Copy, paste and print describes each warning.