2014-10-02 16:05:44 -04:00
'use strict' ;
2013-11-14 14:44:57 -05:00
2014-10-02 16:05:44 -04:00
var axe = require ( 'axe-logger' ) ;
2014-06-18 11:09:04 -04:00
2014-10-02 16:05:44 -04:00
var er = { } ;
er . attachHandler = function ( scope ) {
scope . onError = function ( options ) {
if ( ! options ) {
scope . $apply ( ) ;
return ;
}
2013-11-14 14:44:57 -05:00
2014-10-02 16:05:44 -04:00
axe . error ( ( options . errMsg || options . message ) + ( options . stack ? ( '\n' + options . stack ) : '' ) ) ;
2013-11-14 14:44:57 -05:00
2014-10-02 16:05:44 -04:00
scope . state . dialog = {
open : true ,
title : options . title || 'Error' ,
message : options . errMsg || options . message ,
faqLink : options . faqLink ,
positiveBtnStr : options . positiveBtnStr || 'Ok' ,
negativeBtnStr : options . negativeBtnStr || 'Cancel' ,
showNegativeBtn : options . showNegativeBtn || false ,
showBugReporter : ( typeof options . showBugReporter !== 'undefined' ? options . showBugReporter : ! options . title ) , // if title is set, presume it's not an error by default
callback : options . callback
2013-11-14 14:44:57 -05:00
} ;
2014-10-02 16:05:44 -04:00
// don't call apply for synchronous calls
if ( ! options . sync ) {
scope . $apply ( ) ;
}
2013-11-14 14:44:57 -05:00
} ;
2014-10-02 16:05:44 -04:00
} ;
2013-11-14 14:44:57 -05:00
2014-10-08 06:34:34 -04:00
module . exports = er ;