add better error handling for photo upload

This commit is contained in:
Brandon Egger 2023-08-24 10:36:18 -05:00
parent 2be3d16365
commit 6253668e8a

View File

@ -51,6 +51,13 @@ const handler: NextApiHandler = async (req, res) => {
}
);
try {
await uploadPhoto;
} catch (error) {
res.writeHead(500, JSON.stringify((error as Error).message)).end();
return;
}
const photoBuffer = fs.readFileSync((await uploadPhoto).filepath);
try {