I want to use regular expression for error message...
try {
throw new Error("Foo 'bar'");
} catch (err) {
console.log(getInQuotes(err));
}
... where getInQuotes is a function for string:
var getInQuotes = function(str) {
var re;
re = /'([^']+)'/g;
return str.match(re);
};
... but got error:
Object Error: Foo 'bar' has no method 'match'
Although it works for usual string:
console.log(getInQuotes("Hello 'world'"));
result:
[ '\'world\'' ]
Tried to stringify Error object ...
console.log("stringify: " + JSON.stringify(err));
... but it's empty:
stringify: {}