Skip to content

Commit

Permalink
Fix TypeScript error
Browse files Browse the repository at this point in the history
  • Loading branch information
buzz committed Sep 2, 2021
1 parent 521e9cb commit b670770
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/mediainfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ class MediaInfo implements MediaInfoInterface {
const safeSize = Math.min(this.options.chunkSize as number, fileSize - offset)
dataValue = readChunk(safeSize, offset)
} catch (e) {
return callback('', e)
if (e instanceof Error) {
return callback('', e)
} else if (typeof e === 'string') {
return callback('', new Error(e))
}
}
if (dataValue instanceof Promise) {
dataValue.then(readNextChunk).catch((e) => callback('', e))
} else {
} else if (dataValue !== undefined) {
readNextChunk(dataValue)
}
}
Expand Down

0 comments on commit b670770

Please sign in to comment.