
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
- Appwrite functions can't connect to data...
I'm trying to create a function that queries my database, but all database operations timeout from within the function, even though CLI access works perfectly. ...
- Error
I'm trying to get sellerId using account.get() in my appwrite function and this is the error message I'm getting: "Failed to send notification to seller 6865bf...
- Is there a timeframe for updating dart r...
Dart 3.5 is already one year old, and the following versions have introduced very important features for the language. Is there a roadmap or timeframe for when...
