SMTPError is a rather an interface than real class

This commit is contained in:
Piotr Roszatycki
2017-11-10 14:37:25 +01:00
parent 8a10f48cbe
commit fb8bac85f5
2 changed files with 10 additions and 7 deletions
+6 -4
View File
@@ -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 {
+4 -3
View File
@@ -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(() => {