Verbose Error Messages and Stack Traces
Overview
Example

Last updated
Was this helpful?

Last updated
Was this helpful?
Was this helpful?
module.exports.calc = function (req, res) {
if (req.body.eqn) {
res.render('app/calc', {
output: mathjs.eval(req.body.eqn)
})
} else {
res.render('app/calc', {
output: 'Enter a valid math string like (3+3)*2'
})
}
}module.exports.calc = function (req, res) {
if(vh.vEqn(req.body.eqn)){
try{
if (req.body.eqn) {
res.render('app/calc', {
output: mathjs.eval(req.body.eqn)
})
} else {
res.render('app/calc', {
output: 'Enter a valid math string like (3+3)*2'
})
}
}catch(err){
res.render('app/calc', {
output: 'Enter a valid math string like (3+3)*2'
})
}
}else{
res.render('app/calc', {
output: 'Enter a valid math string like (3+3)*2'
})
}
}