Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch Handler #335

Open
mlmoravek opened this issue May 6, 2021 · 1 comment
Open

Catch Handler #335

mlmoravek opened this issue May 6, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request frontend Requires work from frontend site medium Medium priority: Should be completed until the due date

Comments

@mlmoravek
Copy link
Collaborator

mlmoravek commented May 6, 2021

Reason (Why?)
Currently no error will be shown to the user if an ajax request failed.

Solution (What?)
Add catch handler to loadPosts function and show a error message to the user

Acceptance criteria
The User will see if when no data could be loaded.

@mlmoravek mlmoravek added enhancement New feature or request refactoring frontend Requires work from frontend site labels May 6, 2021
@KaiDrie KaiDrie added the high High priority: Should be completed as fast as possible label May 21, 2021
@DianaPankratz DianaPankratz added this to the 08.07.2021 milestone May 21, 2021
@DianaPankratz DianaPankratz added medium Medium priority: Should be completed until the due date and removed high High priority: Should be completed as fast as possible labels May 27, 2021
@mlmoravek mlmoravek self-assigned this Jun 10, 2021
@mlmoravek mlmoravek removed their assignment Jun 28, 2021
@DianaPankratz DianaPankratz removed this from the 28.06.2021 milestone Jun 28, 2021
@mhendlich
Copy link
Collaborator

mhendlich commented Oct 27, 2021

Axios supports global interceptors(middleware) that can be used for this.
Example from another codebase:

axiosInstance.interceptors.response.use(
    res => res,
    err => {
        const status = err?.response?.status

        if (status === 400 || status === 500) {
            const data = err.response.data

            if (typeof data === 'object' && data.message) {
                const text = `Es ist ein Fehler aufgetreten:
      
${data.message}`

                openErrorNotification(text)
            } else if (typeof data === 'string' && data.length !== 0) {
                const text = `Es ist ein Fehler aufgetreten:
      
${data}`

                openErrorNotification(text)
            } else {
                openErrorNotification('Es ist ein Fehler aufgetreten')
            }
        }
        throw err
    },
)

@mhendlich mhendlich self-assigned this Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request frontend Requires work from frontend site medium Medium priority: Should be completed until the due date
Projects
None yet
Development

No branches or pull requests

5 participants