-
Notifications
You must be signed in to change notification settings - Fork 0
update: body height limit #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,11 +19,12 @@ export default function calculatePageLayout( | |
| const footerY = footerHeight ? -1 : 0; | ||
| const bodyY = footerHeight - (pageHeight ? 1 : 0); | ||
| const backgroundY = 0; | ||
| const BODY_HEIGHT_MIN_FACTOR = 0.25; | ||
|
|
||
| if (bodyHeight < pageHeight / 3) { | ||
| throw new Error( | ||
| `Header/footer too big. Page height: ${pageHeight}px, header: ${headerHeight}px, footer: ${footerHeight}px, body: ${bodyHeight}px.` | ||
| ); | ||
| if (bodyHeight < pageHeight * BODY_HEIGHT_MIN_FACTOR) { | ||
| throw new Error('The header and footer are too large to fit on the page. Please reduce their size and try again.', { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Želim ovu poruku prikazati na Exporteru u nekakvom error templateu, pa sam je učinio više user-friendly.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Upravo je ovo dio na koji sam mislio kad sam rekao na tasku da error handling ne bi trebali raditi u libu. Lib je iskljucivo developer facing stvar -> errori koje ovdje throwamo moraju imati informacije korisne za developere, ne za usere. Ovim gubimo cijeli reasoning zasto je throwano i sto se desilo sa velicinama hadera / footera / bodya. Ono sto bi trebalo napraviti je na exporteru handleati ovdje throwane errore u catch bloku: // handle-export-document.ts linija ~98
if (Error.isError(error) && error.message.startsWith('Header/footer too big.') {
return 'The header and footer are too large to fit on the page...'
}i onda taj kod handleati unutar rute da se returna kako spada. |
||
| cause: `Page height: ${pageHeight}px, header: ${headerHeight}px, footer: ${footerHeight}px, body: ${bodyHeight}px`, | ||
| }); | ||
| } | ||
|
|
||
| return { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jako nisam fan rjesavanja lokalnih problema na globalnoj razini. To uvijek, ali bas uvijek vodi u krivom smjeru i onda hrpa bugova ispliva.
Ovo nikako ne bi rjesavao hardcodiranjem, pogotovo ne u libu - jer to vodi prema panicnom republishanju paketa da se pofixaju neki drugi problemi koji ce tek isplivati.
Ovo trebamo rjesavat na nacin na genericki nacin - da se otvori konfiguracijska opcija overrideanja tog faktora, pa onda overrideaj na exporteru prilikom inicijalizacije. Pa ako se pokaze da je override los, puno ce se brze moc reagirat uz daleko manji friction.