Comments (3)
You're absolutely right, the current frontend error management lacks the ability to extract error messages from backend errors. The reason is we're doing toast.error(
Could not create org: ${err});
which converts the error object to a string via a JS string template, only extracting the Error.message (native behavior of error.toString()
) instead of actually extracting the message from the backend response. These errors are actually axios errors and the backend message can be retrieved from error.response.data.message
. A safe option would be to do it this way: toast.error(
Could not create org: ${error.response?.data?.message || error.message});
. But I would extract this to a function to generalize the error handling behavior across the app.
As Meli is meant to be deployed on your VPS, 1
is a sane default, as we expect that you most likely not want your users to create more organizations.
from meli.
@gemapin It appears somebody already did "extract this to a function". It is called extractExrrorMessage
and it can be found in ui/src/utils/extract-exrror-message
. I thought the name of the file was a typo until I saw it matches the name of the function. Is this a typo? I don't see why the extra x
is in there. But in any case, this appears to be the function to use to extract an error message generically. I can submit a pull request with all the toast
calls invoking this function. But do you want me to rename this function while I'm at it?!?
from meli.
Oh yes that's right, I think I created this function and left that aside for some reason. You can definitely reuse that and make the changes you suggested. You can also rename the function, it's a typo 😅 . I'd change the function however, because I realize that the response.data.message
is potentially null, so to be safe here's what I'd do:
import { AxiosError } from 'axios';
export function extractErrorMessage(err: any) {
let message: string;
if (err.isAxiosError) {
message = (err as AxiosError).response?.data?.message;
}
return message || err.message;
}
from meli.
Related Issues (20)
- How to delete an organization? HOT 3
- Any way to upload branches/sites with API key (instead of token) via CLI or API? HOT 2
- Configuration Issues HOT 2
- Gitlab Docs are Wrong HOT 2
- Protect sites with user authentication HOT 4
- Helm chart? HOT 7
- Display Invitation Link HOT 3
- Handling of MAX_ORGS is not right HOT 3
- Site Domains HOT 5
- Password not working HOT 1
- Add domain redirection
- Is this project dead? HOT 1
- Adding a manually created SSL certificate to Meli
- Project state? HOT 2
- Deploy Remix app with Prisma and Postgres HOT 3
- Is document site down ? HOT 2
- Support rewrites
- Does it support special path reverse proxy?
- Not Support Gitea Actions Request failed with status code 404 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meli.