2015-03-16 17:44:14 -04:00
|
|
|
import {Injectable} from 'angular2/di';
|
2015-02-16 08:35:27 -05:00
|
|
|
import {isPresent, print} from 'angular2/src/facade/lang';
|
|
|
|
import {ListWrapper, isListLikeIterable} from 'angular2/src/facade/collection';
|
|
|
|
|
2015-03-31 18:47:11 -04:00
|
|
|
/**
|
2015-04-10 06:45:02 -04:00
|
|
|
* @exportedAs angular2/angular2
|
2015-03-31 18:47:11 -04:00
|
|
|
*/
|
2015-03-16 17:44:14 -04:00
|
|
|
@Injectable()
|
2015-02-16 08:35:27 -05:00
|
|
|
export class ExceptionHandler {
|
|
|
|
call(error, stackTrace = null, reason = null) {
|
|
|
|
var longStackTrace = isListLikeIterable(stackTrace) ? ListWrapper.join(stackTrace, "\n\n") : stackTrace;
|
|
|
|
var reasonStr = isPresent(reason) ? `\n${reason}` : '';
|
|
|
|
print(`${error}${reasonStr}\nSTACKTRACE:\n${longStackTrace}`);
|
|
|
|
}
|
|
|
|
}
|