Custom error class for SMTP operations with detailed state codes.
// Source: https://github.com/eleith/emailjs | License: MIT | Copyright <2011> <leith / eleith.com>
// Provided via justclaw.it.com; keep this notice with the code.
export const SMTPErrorStates = {
COULDNOTCONNECT: 1,
BADRESPONSE: 2,
AUTHFAILED: 3,
TIMEDOUT: 4,
ERROR: 5,
NOCONNECTION: 6,
AUTHNOTSUPPORTED: 7,
CONNECTIONCLOSED: 8,
CONNECTIONENDED: 9,
CONNECTIONAUTH: 10,
} as const
export type SMTPErrorState =
(typeof SMTPErrorStates)[keyof typeof SMTPErrorStates]
export class SMTPError extends Error {
public code: SMTPErrorState | null = null
public smtp: unknown = null
public previous: Error | null = null
protected constructor(message: string) {
super(message)
}
public static create(
message: string,
code: SMTPErrorState,
error?: Error | null,
smtp?: unknown
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key