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
|
@ -102,10 +102,12 @@
|
|||
"Successfully uploaded receipts"
|
||||
);
|
||||
} else {
|
||||
r.text().then((msg) => {
|
||||
showDialog(
|
||||
"Upload Failure",
|
||||
`Failed to upload receipts: ${r.statusText}`,
|
||||
`Failed to upload receipts: ${r.statusText}\n${msg}`,
|
||||
);
|
||||
});
|
||||
}
|
||||
form.reset();
|
||||
})
|
||||
|
|
|
@ -92,10 +92,14 @@ async def upload_receipts(
|
|||
# notes: Annotated[list[str], fastapi.Form(alias='notes[]')],
|
||||
):
|
||||
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(
|
||||
status_code=fastapi.status.HTTP_400_BAD_REQUEST,
|
||||
detail='Number of uploaded images does not match '
|
||||
'number of date fields',
|
||||
detail=msg,
|
||||
)
|
||||
failed = False
|
||||
async with Paperless() as paperless:
|
||||
|
|
Loading…
Reference in New Issue