Skip to content

Commit

Permalink
Handle errors when uploading files.
Browse files Browse the repository at this point in the history
  • Loading branch information
mosh-hamedani committed Apr 26, 2017
1 parent 5e397cb commit 1296f97
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
10 changes: 5 additions & 5 deletions ClientApp/app/app.error-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ export class AppErrorHandler implements ErrorHandler {
}

handleError(error: any): void {
if (!isDevMode())
Raven.captureException(error.originalError || error);
else
throw error;

this.ngZone.run(() => {
this.toastyService.error({
title: 'Error',
Expand All @@ -23,5 +18,10 @@ export class AppErrorHandler implements ErrorHandler {
timeout: 5000
});
});

if (!isDevMode())
Raven.captureException(error.originalError || error);
else
throw error;
}
}
18 changes: 14 additions & 4 deletions ClientApp/app/components/view-vehicle/view-vehicle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ export class ViewVehicleComponent implements OnInit {
}
}

uploadPhoto() {
var nativeElement: HTMLInputElement = this.fileInput.nativeElement;

uploadPhoto() {
this.progressService.startTracking()
.subscribe(progress => {
this.zone.run(() => {
Expand All @@ -69,9 +67,21 @@ export class ViewVehicleComponent implements OnInit {
null,
() => { this.progress = null; });

this.photoService.upload(this.vehicleId, nativeElement.files[0])
var nativeElement: HTMLInputElement = this.fileInput.nativeElement;
var file = nativeElement.files[0];
nativeElement.value = '';
this.photoService.upload(this.vehicleId, file)
.subscribe(photo => {
this.photos.push(photo);
},
err => {
this.toasty.error({
title: 'Error',
msg: err.text(),
theme: 'bootstrap',
showClose: true,
timeout: 5000
});
});
}
}

0 comments on commit 1296f97

Please sign in to comment.