]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/videos/video-add/video-add.component.ts
Handle error for the video upload
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-add / video-add.component.ts
index 8df4f951be603322bc516e3ebc105cf8cd309976..144879a54c9d2c15704388388bfc02c6585b22e4 100644 (file)
@@ -18,6 +18,7 @@ import { AuthService, User } from '../../shared';
 })
 
 export class VideoAddComponent implements OnInit {
+  error: string = null;
   fileToUpload: any;
   progressBar: { value: number; max: number; } = { value: 0, max: 0 };
   user: User;
@@ -57,11 +58,23 @@ export class VideoAddComponent implements OnInit {
 
         // Print all the videos once it's finished
         this.router.navigate(['VideosList']);
+      },
+
+      fail: (e, data) => {
+        const xhr = data.jqXHR;
+        if (xhr.status === 400) {
+          this.error = xhr.responseText;
+        } else {
+          this.error = 'Unknow error';
+        }
+
+        console.error(data);
       }
     });
   }
 
   uploadFile() {
+    this.error = null;
     this.form.formData = jQuery(this.elementRef.nativeElement).find('form').serializeArray();
     this.form.headers = this.authService.getRequestHeader().toJSON();
     this.form.submit();