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 🙂
TL;DR
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.set statusCode to 4xx
Recommended threads
- Github App "Failed to retrieve access to...
When trying to connect the Github App on 1.8.1 I recieve this error: ```[Error] Method: GET [Error] URL: /v1/vcs/github/callback [Error] Type: Exception [Error]...
- Update from 1.8 to 1.8.1 failing
I have spent the past 2 hours trying to figure this out but I really dont know what to do. 1.8. was a fresh install because the upgrade from 1.7.4 was a total m...
- Realtime not working for some tables
Hi, I've got an issue where I can setup a realtime connection to listen to some tables, but some not all. I have two tables `history` and `users`. Both can be ...