import type { Opt } from '@jet/environment'; import type { Intent } from '@jet/environment/dispatching'; export function addRejectedIntent(error: Error, intent: Intent) { (error as any).rejectedIntent = intent; } export function getRejectedIntent(error: Error): Opt> { return hasRejectedIntent(error) ? error.rejectedIntent : null; } function hasRejectedIntent( error: Error, ): error is Error & { rejectedIntent: Intent } { return 'rejectedIntent' in error; }