From c87ce2fef658c6e43ab8a3f8ab1d6554c4d145bb Mon Sep 17 00:00:00 2001 From: Devonte Date: Tue, 8 Sep 2020 15:38:14 +0100 Subject: [PATCH] fix: log errors, improved messages (#156) Spelling errors, improved error logs. --- src/commands/registration/pbsz.js | 2 +- src/commands/registration/prot.js | 2 +- src/connection.js | 12 ++++++------ src/connector/passive.js | 4 ++++ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/commands/registration/pbsz.js b/src/commands/registration/pbsz.js index bf37910..b4f8e31 100644 --- a/src/commands/registration/pbsz.js +++ b/src/commands/registration/pbsz.js @@ -1,7 +1,7 @@ module.exports = { directive: 'PBSZ', handler: function ({command} = {}) { - if (!this.secure) return this.reply(202, 'Not suppored'); + if (!this.secure) return this.reply(202, 'Not supported'); this.bufferSize = parseInt(command.arg, 10); return this.reply(200, this.bufferSize === 0 ? 'OK' : 'Buffer too large: PBSZ=0'); }, diff --git a/src/commands/registration/prot.js b/src/commands/registration/prot.js index a70da18..6d6ac46 100644 --- a/src/commands/registration/prot.js +++ b/src/commands/registration/prot.js @@ -3,7 +3,7 @@ const _ = require('lodash'); module.exports = { directive: 'PROT', handler: function ({command} = {}) { - if (!this.secure) return this.reply(202, 'Not suppored'); + if (!this.secure) return this.reply(202, 'Not supported'); if (!this.bufferSize && typeof this.bufferSize !== 'number') return this.reply(503); switch (_.toUpper(command.arg)) { diff --git a/src/connection.js b/src/connection.js index eeecdbd..578f053 100644 --- a/src/connection.js +++ b/src/connection.js @@ -129,10 +129,10 @@ class FtpConnection extends EventEmitter { return new Promise((resolve, reject) => { if (letter.socket && letter.socket.writable) { this.log.trace({port: letter.socket.address().port, encoding: letter.encoding, message: letter.message}, 'Reply'); - letter.socket.write(letter.message + '\r\n', letter.encoding, (err) => { - if (err) { - this.log.error(err); - return reject(err); + letter.socket.write(letter.message + '\r\n', letter.encoding, (error) => { + if (error) { + this.log.error('[Process Letter] Socket Write Error', { error: error.message }); + return reject(error); } resolve(); }); @@ -147,8 +147,8 @@ class FtpConnection extends EventEmitter { .then((satisfiedLetters) => Promise.mapSeries(satisfiedLetters, (letter, index) => { return processLetter(letter, index); })) - .catch((err) => { - this.log.error(err); + .catch((error) => { + this.log.error('Satisfy Parameters Error', { error: error.message }); }); } } diff --git a/src/connector/passive.js b/src/connector/passive.js index 8f1ca82..b9705c4 100644 --- a/src/connector/passive.js +++ b/src/connector/passive.js @@ -86,6 +86,10 @@ class Passive extends Connector { } }); }); + }) + .catch((error) => { + this.log.trace(error.message); + throw error; }); }