Skip to content

Commit

Permalink
Throw an error if the data captured is not of the expected width and …
Browse files Browse the repository at this point in the history
…height.
  • Loading branch information
stacey-gammon committed Jun 20, 2018
1 parent d3bee8d commit 2a5840e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,22 @@ export function $combine(
const parseAsObservable = Rx.bindNodeCallback(png.parse.bind(png));
return parseAsObservable(buffer);
},
(screenshot: Screenshot, png: PNG) => ({ screenshot, png })
(screenshot: Screenshot, png: PNG) => {
if (
png.width !== screenshot.dimensions.width ||
png.height !== screenshot.dimensions.height
) {
const errorMessage = `Screenshot captured with width:${
png.width
} and height: ${png.height}) is not of expected width: ${
screenshot.dimensions.width
} and height: ${screenshot.dimensions.height}`;

logger.error(errorMessage);
throw new Error(errorMessage);
}
return { screenshot, png };
}
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ export interface Screenshot {

export interface Logger {
debug: (message: string) => void;
error: (message: string) => void;
warning: (message: string) => void;
}

0 comments on commit 2a5840e

Please sign in to comment.