From fb8bac85f5d4fe1bbd38df4f53637a87444674f2 Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Fri, 10 Nov 2017 14:37:25 +0100 Subject: [PATCH] SMTPError is a rather an interface than real class --- types/nodemailer/lib/smtp-connection.d.ts | 10 ++++++---- types/nodemailer/nodemailer-tests.ts | 7 ++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/types/nodemailer/lib/smtp-connection.d.ts b/types/nodemailer/lib/smtp-connection.d.ts index a02defb461..1215409b46 100644 --- a/types/nodemailer/lib/smtp-connection.d.ts +++ b/types/nodemailer/lib/smtp-connection.d.ts @@ -70,13 +70,15 @@ declare namespace SMTPConnection { dsn?: DSNOptions; } - class SMTPError extends Error { + interface SMTPError extends NodeJS.ErrnoException { /** string code identifying the error, for example ‘EAUTH’ is returned when authentication */ - code: string; + code?: string; /** the last response received from the server (if the error is caused by an error response from the server) */ - response: string; + response?: string; /** the numeric response code of the response string (if available) */ - responseCode: number; + responseCode?: number; + /** command which provoked an error */ + command?: string; } interface SentMessageInfo { diff --git a/types/nodemailer/nodemailer-tests.ts b/types/nodemailer/nodemailer-tests.ts index ea7bb3cc5b..00238d2d5c 100644 --- a/types/nodemailer/nodemailer-tests.ts +++ b/types/nodemailer/nodemailer-tests.ts @@ -1036,9 +1036,10 @@ namespace smtp_connection_test { if (err) throw err; connection.send({ from: 'a@example.com', to: 'b@example.net' }, 'message', (err, info) => { if (err) { - const code: string = err.code; - const response: string = err.response; - const responseCode: number = err.responseCode; + const code: string = err.code || '???'; + const response: string = err.response || '???'; + const responseCode: number = err.responseCode || 0; + const command: string = err.command || '???'; throw err; } connection.reset(() => {