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