Answer the question
In order to leave comments, you need to log in
Why is "e" undefinable?
Why is "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
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question