Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (37 sloc) 1.39 KB
import { Component, ErrorHandler, OnInit, OnDestroy } from '@angular/core';
import { MyAngularErrorHandler } from "./my-angular-error-handler";
import { Subscription } from 'rxjs/Subscription';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit, OnDestroy {
title = "my-angular-4-crasher";
crashId = "";
database = "";
link = "https://www.bugsplat.com";
linkText = "";
logs = "";
bugSplatEventSubscription: Subscription;
constructor(private errorHandler: ErrorHandler) { }
ngOnInit() {
const myAngularErrorHandler = (<MyAngularErrorHandler>this.errorHandler);
this.database = myAngularErrorHandler.database;
this.bugSplatEventSubscription = myAngularErrorHandler.bugsplat.getObservable().subscribe((event) => {
this.crashId = "" + event.responseData.crash_id;
this.link = "https://app.bugsplat.com/individualCrash?database=" + this.database + "&id=" + this.crashId;
this.linkText = "Crash " + this.crashId + " in database " + this.database;
});
}
ngOnDestroy(): void {
if (this.bugSplatEventSubscription) {
this.bugSplatEventSubscription.unsubscribe();
}
}
myEvent(event) {
const error = new Error("foobar!");
this.logs += "BugSplat!" + "<br/>" + error.message + "<br/>" + error.stack + "<br/><br/>";
throw error;
}
}