rbbt.exception = {}
rbbt.exception.null = function(variable, text){
if (variable == null) throw(text)
}
rbbt.exception.report = function(err){
console.log(err)
console.log("Error: " + err)
var stack = err.stack
console.log("Error: " + stack)
if(undefined === stack) stack = "No stack trace"
if (rbbt.modal){
stack = "
- " + stack.replace(/\n/g, '
- ') + '
'
stack = stack.replace(//g,'').replace(/(.*?)@(.*?):(\d+:\d+)<\/li>/g, '$2$3
$1')
rbbt.modal.controller.error(m('.ui.error.message', [m('.header', err), m('.description', m.trust(stack))]), "Application Error")
}else{
console.log(stack)
}
}
rbbt.try = function(func, catch_function){
var f = function(){
try {
return func.apply(this, arguments)
}catch(err){
if (catch_function)
catch_function(err)
else
rbbt.exception.report(err)
}
}
return f
}
rbbt.do_try = function(func){
return rbbt.try(func)()
}