better-smpp
Core

Errors

The typed error hierarchy and how failures map to SMPP statuses.

Every error better-smpp raises extends SmppError and carries the SMPP commandStatus most appropriate for the failure — so server code can respond with it directly, and client code can branch on it without string matching.

import {
  SmppError,          // base class
  SmppCommandError,   // peer answered with a non-zero status / generic_nack
  SmppTimeoutError,   // no response in time, or keepalive declared the link dead
  SmppClosedError,    // operation attempted on / interrupted by a closed connection
  SmppAbortError,     // AbortSignal fired
  SmppProtocolError,  // malformed bytes (encode or decode)
  SmppWindowFullError, // local send-window queue limit reached
} from "@better-smpp/core";

Anatomy

try {
  await client.submitSm(params);
} catch (error) {
  if (error instanceof SmppCommandError) {
    error.commandStatus;     // 0x58
    error.commandStatusName; // "ESME_RTHROTTLED"
    error.response;          // the full response PDU
  }
}
ClassTypical commandStatusRaised when
SmppCommandErrorwhatever the peer sentresponse with non-zero status, or generic_nack
SmppTimeoutErrorESME_RSYSERRrequest timeout; missed keepalives
SmppClosedErrorESME_RSUBMITFAIL / ESME_RSYSERRsend on closed link; pending requests at disconnect
SmppAbortErrorESME_RSYSERRyour AbortSignal fired
SmppProtocolErrorESME_RINVCMDLEN, ESME_RINVTLVSTREAM, ESME_RINVDCS, …malformed PDU bytes; text with a binary dataCoding
SmppWindowFullErrorESME_RMSGQFULwindowQueueLimit exceeded locally

Status codes

All 68 ESME_* codes are exported with a reverse lookup:

import { CommandStatus, commandStatusName } from "@better-smpp/core";

CommandStatus.ESME_ROK;        // 0
CommandStatus.ESME_RTHROTTLED; // 0x58
commandStatusName(0x58);       // "ESME_RTHROTTLED"
commandStatusName(0x7777);     // undefined (vendor-specific)

Rule of thumb for handling SmppCommandError from submits:

  • ESME_RTHROTTLED, ESME_RMSGQFUL — transient; the client's built-in throttle backoff already retries these.
  • ESME_RINVDSTADR, ESME_RINVSRCADR, ESME_RINVDCS — permanent for that message; don't retry.
  • ESME_RINVBNDSTS, ESME_RALYBND — session-state problems; check your bind flow.

On this page