/**

*/
assert api.cgi
const ob = api.ob
ob.push()
const obLevel = ob.level()
var err = catch{
    api.import('cgi/init')
    api.cgi.dispatchRoute()
}
while( ob.level() > obLevel){
    ob.pop() // discard accumulated output
}
// we are only here if an exception is thrown because it exit()s on success
//api.ob.level() && api.ob.clear()
if(api.cgi.httpStatus() < 500){
    api.cgi.httpStatus(500, "Caught Exception")
}
api.cgi.scrubException && (err = api.cgi.scrubException(err))
api.cgi.setContentType('application/json')
print("%1$-1J".applyFormat(object{exception:err}))
api.cgi.send()
