Changed Error string to Error Class

This commit is contained in:
killer069
2021-09-15 17:30:57 +05:30
parent ae737e7460
commit 7d8b328e2f
2 changed files with 12 additions and 8 deletions

View File

@@ -91,8 +91,11 @@ export class LiveStreaming{
continue
}
await new Promise(async(resolve, reject) => {
let stream = await request_stream(this.base_url + segment).catch((err) => {this.stream.emit('error', err); return null})
if(!stream) return
let stream = await request_stream(this.base_url + segment).catch((err: Error) => err)
if(stream instanceof Error){
this.stream.emit('error', stream)
return
}
this.request = stream
stream.pipe(this.stream, { end : false })
stream.on('end', () => {
@@ -181,8 +184,9 @@ export class Stream {
headers : {
"range" : `bytes=${this.bytes_count}-${end >= this.content_length ? '' : end}`
}
}).catch((err) => {this.stream.emit('error', err); return null})
if(!stream) {
}).catch((err: Error) => err)
if(stream instanceof Error){
this.stream.emit('error', stream)
this.data_ended = true
this.bytes_count = 0
this.per_sec_bytes = 0