function errorHandler(err, req, res, next){
var idx

    if(!err) return next()
    if (err.status) res.statusCode = err.status
    if (res.statusCode < 400) res.statusCode = 500
    log('errorHandler: ', err.stack || err), log('URL: ' + req.url)
    log('data: ', req.json || 'null')// log JSON data (from stores, etc.)

    if('string' == typeof err){
        // action err + raw (double error)
        if(0 < (idx = err.indexOf('error index:'))){
            err = err.slice(idx)
        }
    } else if(('MongoError' == err.name) ||
              (err.stack && 0 == err.stack.indexOf('MongoError'))){
        // raw DB errors
        err = String(err.err)// use short message
        if(0 < (idx = err.indexOf('error index:'))){
            err = err.slice(idx)
        }
    }

    return res.json({
        url: req.url, err: err.stack || err,// frontend must wrap this in pretty UI
        success: false, data: err.stack || err// compatible with 'App.proxy.CRUD'
    })
}

module.exports = errorHandler

@@ -221,17 +221,21 @@
  %7C%7C err)
-,
+%0D%0A   
  log('UR
@@ -238,18 +238,17 @@
 ('URL: '
- +
+,
  req.url
@@ -798,24 +798,138 @@
 %7D%0D%0A    %7D%0D%0A%0D%0A
+    if(res._header %7C%7C res.finished)%7B// %60res%60 was sent already%0D%0A        res.json = pushUncaughtException%0D%0A    %7D%0D%0A%0D%0A
     return r

handle case if `res` is done via pushUncaughtException