Почему "e" - undefined?
var util = require('util');
var phrases = {
"Hello": "Привет",
"world": "мир"
}
function PhraseError(message) {
this.message = message;
}
util.inherits(PhraseError, Error);
PhraseError.prototype.name = "PhraseError";
function HttpError(status, message) {
this.status = status;
this.message = message;
}
util.inherits(HttpError, Error);
HttpError.prototype.name = "HttpError";
function getPhrase(name) {
if (!phrases[name]) {
throw PhraseError('Phrase is not defind' + name)
}
return phrases[name];
}
function makePage(url) {
if (url !== "index.html") {
throw HttpError(404, "Page is not defind");
}
return util.format("%s, %s!", getPhrase("asdasd"), getPhrase("world"));
}
try {
var page = makePage("index.html");
console.log(page);
} catch (e) {
console.log(e); //undefind
}