Type guard that reports whether a caught value is an error raised by the SDK.
It accepts any Error carrying a string kind, which every BaseError has, so it also
recognizes SDK errors that crossed a bundle boundary, where instanceof BaseError can fail
because two copies of the class are loaded. It narrows to DIDError, the union of the
seven subclasses, so a switch on kind inside the branch narrows
further to one class and its own fields — error.status on an HttpError,
error.key on a ValidationError.
The duck-typing is wider than the union it promises, so keep the default branch of a switch
total — DIDError says why.
try { awaitagentManager.chat('What is the distance to the moon?'); } catch (error) { if (isDIDError(error)) { console.error(error.kind, error.toJson());
Type guard that reports whether a caught value is an error raised by the SDK.
It accepts any
Errorcarrying a stringkind, which every BaseError has, so it also recognizes SDK errors that crossed a bundle boundary, whereinstanceof BaseErrorcan fail because two copies of the class are loaded. It narrows to DIDError, the union of the seven subclasses, so aswitchon kind inside the branch narrows further to one class and its own fields —error.statuson an HttpError,error.keyon a ValidationError.The duck-typing is wider than the union it promises, so keep the
defaultbranch of aswitchtotal — DIDError says why.