isTrap(reply: Reply): reply is TrapReply
Checks if a reply is a trap (error) reply
Type guard function that narrows the Reply type to TrapReply.
Handle trap errors
Handle trap errors
import { assertEquals } from "@std/assert"; import { parseReply, isTrap } from "@hertzg/routeros-api/protocol/reply"; const reply = parseReply(["!trap", "=message=no such item"]); if (isTrap(reply)) { // TypeScript knows reply has message property here assertEquals(reply.message, "no such item"); }
reply: Reply
The reply to check
reply is TrapReply
True if the reply is a TrapReply