_alnes_Original post
Rank 2: Process
Its an easy question. Ive this try/catch:
TypeScript
try { const userResponse: Models.User<Models.Preferences> = await users.get(id); const user = JSON.stringify(userResponse);
return res.send(user); } catch (err) { log('Appwrite getUser: Error getting user. id: ' + id); return res.send(err); }```
Since there is no res.status, what is the best way to send an error to the client? Just res.send it? This will not trigger the try/catch error handling on the client...
thanks 🙂Summary
To forward an error to the client without res.status in an Express application, developers can set the statusCode manually to a 4xx code. A common approach is to use the res.send method to send the error message to the client but keep in mind that this may not trigger the try/catch error handling on the client side.