node.js express.js Error handling in View

I am very new to node.js and express.js and in programming concepts. I already made a basic MVC modeled app on node and express.

My problem is how do you handle error, I got this following code:

exports.submitBloodRequest=function(kaiseki,resView,request){
    var params = {
        bloodCenterId:request.session.centerID,
        bloodTypeId: request.body.bloodType,
        requestQuantity:request.body.numberOfDonors
    }
    kaiseki.createObject('blood_center_request', params, function(err, res, body, success) {
      if(success){
        resView.redirect('/bloodRequest')
      }else{
        //WHAT TO DO HERE?
      }
    });
}

Kaiseki is just a middleware for parse.com, I don't know what to do if it got error. Usually I use ajaxForm.js to look for BadRequest then use javascript to display error message in my view.

I want my error to appear in the same page, where it is success, should I pass a json error to my view?

Or still use ajaxForm.js and instead of res.render or res.redirect I should use res.status(500)

Is there anyway to handle the error and showing it into the view. Without using any javascript to detect BadRequest?

And can a view have a optional variable? In my view If I didnt pass any value on it it gives me error like if i have #{variable} it asks for its value. Can it be made to be optional? Im using Jade Template

To respond to an XHR request with an error you can do something like return resView.status(500).send(err); which will send the err object back as JSON. If you want to render an HTML error page instead you can do return resView.status(500).locals({err: err}).render('/errorPage');

You didn't say which template engine you are using but most likely the #{} version will automatically escape HTML characters for you (turn < into &lt;, etc) to avoid XSS attacks and rendering problems whereas !{} will render the contents of the variable directly without escaping, which is dangerous if the variable contains any user-generated content, but necessary if the variable has HTML you want rendered by the browser.