aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-07-23 11:07:30 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-07-23 11:07:30 +0200
commit0c31c33dcb0baaa8d3aeedb63336dfe2ae6e5585 (patch)
treeeacb501b721e04e5de3fa1f53ff4b8ec832d8765 /client/src/app
parent407c4473ad6b1aa30c3d77bd75e3c273d03989b8 (diff)
downloadPeerTube-0c31c33dcb0baaa8d3aeedb63336dfe2ae6e5585.tar.gz
PeerTube-0c31c33dcb0baaa8d3aeedb63336dfe2ae6e5585.tar.zst
PeerTube-0c31c33dcb0baaa8d3aeedb63336dfe2ae6e5585.zip
Better webtorrent error handling
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/videos/video-watch/video-watch.component.ts23
1 files changed, 18 insertions, 5 deletions
diff --git a/client/src/app/videos/video-watch/video-watch.component.ts b/client/src/app/videos/video-watch/video-watch.component.ts
index 05a2c296c..cd11aa33c 100644
--- a/client/src/app/videos/video-watch/video-watch.component.ts
+++ b/client/src/app/videos/video-watch/video-watch.component.ts
@@ -81,10 +81,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
81 self.player = this 81 self.player = this
82 }) 82 })
83 83
84 this.errorsSub = this.webTorrentService.errors.subscribe(err => { 84 this.errorsSub = this.webTorrentService.errors.subscribe(err => this.handleError(err))
85 const message = typeof err === 'string' ? err : err.message
86 this.notificationsService.error('Error', message)
87 })
88 } 85 }
89 86
90 ngOnDestroy () { 87 ngOnDestroy () {
@@ -117,7 +114,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
117 // So we create a timer to inform the user the load is abnormally long 114 // So we create a timer to inform the user the load is abnormally long
118 this.errorTimer = window.setTimeout(() => this.loadTooLong(), VideoWatchComponent.LOADTIME_TOO_LONG) 115 this.errorTimer = window.setTimeout(() => this.loadTooLong(), VideoWatchComponent.LOADTIME_TOO_LONG)
119 116
120 this.webTorrentService.add(this.video.magnetUri, torrent => { 117 const torrent = this.webTorrentService.add(this.video.magnetUri, torrent => {
121 // Clear the error timer 118 // Clear the error timer
122 window.clearTimeout(this.errorTimer) 119 window.clearTimeout(this.errorTimer)
123 // Maybe the error was fired by the timer, so reset it 120 // Maybe the error was fired by the timer, so reset it
@@ -143,6 +140,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
143 140
144 this.runInProgress(torrent) 141 this.runInProgress(torrent)
145 }) 142 })
143
144 torrent.on('error', err => this.handleError(err))
145 torrent.on('warning', err => this.handleError(err))
146 } 146 }
147 147
148 setLike () { 148 setLike () {
@@ -250,6 +250,19 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
250 return this.video.isBlackistableBy(this.authService.getUser()) 250 return this.video.isBlackistableBy(this.authService.getUser())
251 } 251 }
252 252
253 private handleError (err: any) {
254 const errorMessage: string = typeof err === 'string' ? err : err.message
255 let message = ''
256
257 if (errorMessage.indexOf('http error') !== -1) {
258 message = 'Cannot fetch video from server, maybe down.'
259 } else {
260 message = errorMessage
261 }
262
263 this.notificationsService.error('Error', message)
264 }
265
253 private checkUserRating () { 266 private checkUserRating () {
254 // Unlogged users do not have ratings 267 // Unlogged users do not have ratings
255 if (this.isUserLoggedIn() === false) return 268 if (this.isUserLoggedIn() === false) return