Permalink
Browse files

Bubble up better errors from Address parser

  • Loading branch information...
1 parent 00833b7 commit 0e591948a05a179251040c073e9198bc434926a5 Matt Sergeant committed Nov 13, 2013
Showing with 14 additions and 4 deletions.
  1. +2 −2 address.js
  2. +2 −2 connection.js
  3. +10 −0 tests/address.js
View
@@ -85,7 +85,7 @@ Address.prototype.parse = function (addr) {
var matches;
if (!(matches = user_host_re.exec(addr))) {
- throw new Error("Failed to parse address: " + addr);
+ throw new Error("Invalid domain in address: " + addr);
}
var localpart = matches[1];
@@ -107,7 +107,7 @@ Address.prototype.parse = function (addr) {
return;
}
else {
- throw new Error("Failed to parse address: " + addr);
+ throw new Error("Invalid local part in address: " + addr);
}
}
View
@@ -1115,7 +1115,7 @@ Connection.prototype.cmd_mail = function(line) {
else {
this.logerror(err);
}
- return this.respond(501, "Command parsing failed");
+ return this.respond(501, ["Command parsing failed", err]);
}
// Get rest of key=value pairs
@@ -1164,7 +1164,7 @@ Connection.prototype.cmd_rcpt = function(line) {
else {
this.logerror(err);
}
- return this.respond(501, "Command parsing failed");
+ return this.respond(501, ["Command parsing failed", err]);
}
// Get rest of key=value pairs
View
@@ -46,5 +46,15 @@ exports.bad = {
test.ok(true);
}
test.done();
+ },
+ '<user@example.com>.': function (test) {
+ test.expect(1);
+ try {
+ var address = new Address('<user@example.com.>');
+ }
+ catch (e) {
+ test.ok(true);
+ }
+ test.done();
}
};

0 comments on commit 0e59194

Please sign in to comment.