Skip to content

Commit

Permalink
feat(print): throw unsupported operation when content area is empty (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiago Perrotta authored Jul 10, 2023
1 parent fb69142 commit 71a8b5c
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/bidiMapper/domains/context/browsingContextImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,14 +816,24 @@ export class BrowsingContextImpl {
cdpParams.preferCSSPageSize = !params.shrinkToFit;
}

const result = await this.#cdpTarget.cdpClient.sendCommand(
'Page.printToPDF',
cdpParams
);

return {
data: result.data,
};
try {
const result = await this.#cdpTarget.cdpClient.sendCommand(
'Page.printToPDF',
cdpParams
);
return {
data: result.data,
};
} catch (error: any) {
// Effectively zero dimensions.
if (
(error as Error).message ===
'invalid print parameters: content area is empty'
) {
throw new UnsupportedOperationException(error.message);
}
throw error;
}
}

async close(): Promise<void> {
Expand Down

0 comments on commit 71a8b5c

Please sign in to comment.