From 14e5f87cc339395ce9c2074dfeb55e20cf868db3 Mon Sep 17 00:00:00 2001 From: Tyler Stewart Date: Thu, 11 May 2017 15:36:49 -0600 Subject: [PATCH] fix: allow error messages to be set via catch --- src/commands/registration/dele.js | 2 +- src/commands/registration/list.js | 2 +- src/commands/registration/mdtm.js | 2 +- src/commands/registration/mkd.js | 2 +- src/commands/registration/retr.js | 2 +- src/commands/registration/rnfr.js | 2 +- src/commands/registration/rnto.js | 2 +- src/commands/registration/size.js | 2 +- src/commands/registration/stat.js | 2 +- src/commands/registration/stor.js | 2 +- src/commands/registration/user.js | 3 ++- 11 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/commands/registration/dele.js b/src/commands/registration/dele.js index 9900945..9ea3c76 100644 --- a/src/commands/registration/dele.js +++ b/src/commands/registration/dele.js @@ -12,7 +12,7 @@ module.exports = { }) .catch(err => { log.error(err); - return this.reply(550); + return this.reply(550, err.message); }); }, syntax: '{{cmd}} [path]', diff --git a/src/commands/registration/list.js b/src/commands/registration/list.js index e721958..1e7b9e5 100644 --- a/src/commands/registration/list.js +++ b/src/commands/registration/list.js @@ -48,7 +48,7 @@ module.exports = { }) .catch(err => { log.error(err); - return this.reply(err.code || 451, err.message || 'No directory'); + return this.reply(451, err.message || 'No directory'); }) .finally(() => { this.connector.end(); diff --git a/src/commands/registration/mdtm.js b/src/commands/registration/mdtm.js index a465d72..f95fcf8 100644 --- a/src/commands/registration/mdtm.js +++ b/src/commands/registration/mdtm.js @@ -14,7 +14,7 @@ module.exports = { }) .catch(err => { log.error(err); - return this.reply(550); + return this.reply(550, err.message); }); }, syntax: '{{cmd}} [path]', diff --git a/src/commands/registration/mkd.js b/src/commands/registration/mkd.js index 2d0bc92..3719bbb 100644 --- a/src/commands/registration/mkd.js +++ b/src/commands/registration/mkd.js @@ -14,7 +14,7 @@ module.exports = { }) .catch(err => { log.error(err); - return this.reply(550); + return this.reply(550, err.message); }); }, syntax: '{{cmd}}[path]', diff --git a/src/commands/registration/retr.js b/src/commands/registration/retr.js index 364bac2..c994e7f 100644 --- a/src/commands/registration/retr.js +++ b/src/commands/registration/retr.js @@ -29,7 +29,7 @@ module.exports = { }) .catch(err => { log.error(err); - return this.reply(551); + return this.reply(551, err.message); }) .finally(() => { this.connector.end(); diff --git a/src/commands/registration/rnfr.js b/src/commands/registration/rnfr.js index 9342090..d964925 100644 --- a/src/commands/registration/rnfr.js +++ b/src/commands/registration/rnfr.js @@ -14,7 +14,7 @@ module.exports = { }) .catch(err => { log.error(err); - return this.reply(550); + return this.reply(550, err.message); }); }, syntax: '{{cmd}} [name]', diff --git a/src/commands/registration/rnto.js b/src/commands/registration/rnto.js index 3f66c9d..3f3305f 100644 --- a/src/commands/registration/rnto.js +++ b/src/commands/registration/rnto.js @@ -17,7 +17,7 @@ module.exports = { }) .catch(err => { log.error(err); - return this.reply(550); + return this.reply(550, err.message); }) .finally(() => { delete this.renameFrom; diff --git a/src/commands/registration/size.js b/src/commands/registration/size.js index 1a940a0..a81dcc4 100644 --- a/src/commands/registration/size.js +++ b/src/commands/registration/size.js @@ -12,7 +12,7 @@ module.exports = { }) .catch(err => { log.error(err); - return this.reply(550); + return this.reply(550, err.message); }); }, syntax: '{{cmd}} [path]', diff --git a/src/commands/registration/stat.js b/src/commands/registration/stat.js index a611e9d..c6ede7d 100644 --- a/src/commands/registration/stat.js +++ b/src/commands/registration/stat.js @@ -33,7 +33,7 @@ module.exports = { }) .catch(err => { log.error(err); - return this.reply(450); + return this.reply(450, err.message); }); } else { return this.reply(211, 'Status OK'); diff --git a/src/commands/registration/stor.js b/src/commands/registration/stor.js index d59facf..ed8b2e4 100644 --- a/src/commands/registration/stor.js +++ b/src/commands/registration/stor.js @@ -32,7 +32,7 @@ module.exports = { }) .catch(err => { log.error(err); - return this.reply(553); + return this.reply(550, err.message); }) .finally(() => { this.connector.end(); diff --git a/src/commands/registration/user.js b/src/commands/registration/user.js index ae9a981..1070f34 100644 --- a/src/commands/registration/user.js +++ b/src/commands/registration/user.js @@ -6,6 +6,7 @@ module.exports = { this.username = command.arg; if (!this.username) return this.reply(501, 'Must send username requirement'); + if (this.server.options.anonymous === true) { return this.login(this.username, '@anonymous') .then(() => { @@ -13,7 +14,7 @@ module.exports = { }) .catch(err => { log.error(err); - return this.reply(530, err || 'Authentication failed'); + return this.reply(530, err.message || 'Authentication failed'); }); } return this.reply(331);