Improve error reporting
Log an error when images/dates do not match. Also, show the response body in the error modal on the client side.python
parent
c6f570100b
commit
d29e9ee89a
10
index.html
10
index.html
|
@ -102,10 +102,12 @@
|
||||||
"Successfully uploaded receipts"
|
"Successfully uploaded receipts"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
showDialog(
|
r.text().then((msg) => {
|
||||||
"Upload Failure",
|
showDialog(
|
||||||
`Failed to upload receipts: ${r.statusText}`,
|
"Upload Failure",
|
||||||
);
|
`Failed to upload receipts: ${r.statusText}\n${msg}`,
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
form.reset();
|
form.reset();
|
||||||
})
|
})
|
||||||
|
|
|
@ -92,10 +92,14 @@ async def upload_receipts(
|
||||||
# notes: Annotated[list[str], fastapi.Form(alias='notes[]')],
|
# notes: Annotated[list[str], fastapi.Form(alias='notes[]')],
|
||||||
):
|
):
|
||||||
if len(dates) != len(images):
|
if len(dates) != len(images):
|
||||||
|
msg = (
|
||||||
|
f'Number of uploaded images ({len(images)})'
|
||||||
|
f' does not match number of date fields ({len(dates)})'
|
||||||
|
)
|
||||||
|
log.warning('%s', msg)
|
||||||
raise fastapi.HTTPException(
|
raise fastapi.HTTPException(
|
||||||
status_code=fastapi.status.HTTP_400_BAD_REQUEST,
|
status_code=fastapi.status.HTTP_400_BAD_REQUEST,
|
||||||
detail='Number of uploaded images does not match '
|
detail=msg,
|
||||||
'number of date fields',
|
|
||||||
)
|
)
|
||||||
failed = False
|
failed = False
|
||||||
async with Paperless() as paperless:
|
async with Paperless() as paperless:
|
||||||
|
|
Loading…
Reference in New Issue