Skip to content

Commit

Permalink
Add type to examples/unlock
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Nov 15, 2023
1 parent 4a1abb5 commit d626ab2
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions examples/unlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,18 @@ export const handler: Handler<Options> = async ({ deviceId, seam, logger }) => {
)
logger.info({ actionAttempt }, 'unlocked')
} catch (err: unknown) {
if (
isSeamActionAttemptFailedError<LocksUnlockDoorResponse['action_attempt']>(
err,
)
) {
if (isSeamActionAttemptFailedError<UnlockDoorActionAttempt>(err)) {
logger.info({ err }, 'Could not unlock the door')
return
}

if (
isSeamActionAttemptTimeoutError<
LocksUnlockDoorResponse['action_attempt']
>(err)
) {
if (isSeamActionAttemptTimeoutError<UnlockDoorActionAttempt>(err)) {
logger.info({ err }, 'Door took too long to unlock')
return
}

throw err
}
}

type UnlockDoorActionAttempt = LocksUnlockDoorResponse['action_attempt']

0 comments on commit d626ab2

Please sign in to comment.