Skip to content

Commit

Permalink
passing errors instead of strings to observables (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewyakovenko authored Feb 19, 2024
1 parent 9237201 commit 93601bf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yuv-rx",
"version": "0.3.0",
"version": "0.3.1",
"description": "Reading videos as Rx Observables of decoded frames",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ export class YuvParser {
error: subscriber.error,
complete: () => {
if (buffer.length != 0) {
subscriber.error(`Unparsed ${buffer.length} bytes in the end of the stream`);
subscriber.error(new Error(`Unparsed ${buffer.length} bytes in the end of the stream`));
} else if (state == 'reading frame') {
subscriber.error('Parser finished while expecting frame data');
subscriber.error(new Error('Parser finished while expecting frame data'));
} else {
subscriber.complete();
}
Expand Down
4 changes: 2 additions & 2 deletions src/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ function yuv4mpegStream(ffmpeg: string, args: string[], options?: Y4MStreamOptio
child.on('exit', (code?: number, signal?: NodeJS.Signals) => {
exited = true;
if (options?.verbose) {
console.log(`FFMpeg exited with code ${code}, signal ${signal}`);
console.log(new Error(`FFMpeg exited with code ${code}, signal ${signal}`));
}
if (code != null && code == 0) {
if (child.stdout.readableEnded) {
subscriber.complete();
}
} else {
subscriber.error(`FFMpeg exited with exit code ${code}, signal ${signal}`);
subscriber.error(new Error(`FFMpeg exited with exit code ${code}, signal ${signal}`));
}
});
child.stdout.on('end', () => {
Expand Down

0 comments on commit 93601bf

Please sign in to comment.