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

How to handle server side exceptions ? #4944

Open
kingo999 opened this issue Oct 12, 2018 · 0 comments
Open

How to handle server side exceptions ? #4944

kingo999 opened this issue Oct 12, 2018 · 0 comments

Comments

@kingo999
Copy link

Q&A (please complete the following information)

  • OS: windows
  • Browser: chrome, safari
  • Version: latest
  • Method of installation: npm
  • Swagger-UI version: 3.19.0
  • Swagger/OpenAPI version: Swagger 2.0

Swagger-UI configuration options:

SwaggerUi({
            dom_id: '#swaggerContainer',
            url: apidocUrl,
            spec,
            presets: [presets.apis],
            plugins: [this.customPlugins],
            onFailure(data) {
                console.log('Unable to Load SwaggerUI');
                console.log(data);
            },
        });

How can we help?

How do I catch and process any errors thrown on the server side.
eg: 401, 404 etc.

Right now I am just monitoring the loading state with the following

customPlugins = () => ({
        statePlugins: {
            spec: {
                wrapSelectors: {
                    allowTryItOutFor: () => () => false,
                },
                wrapActions: {
                    updateLoadingStatus: ori => (...args) => {
                        const [loadingStatus] = args;
                        this.setState({ isLoading: loadingStatus === 'loading' });
                        this.setState({ loadingStatus });
                        return ori(...args);
                    },
                },
            },
        },
    });

but this does not give me any additional info.

The onFailure callback is never getting called.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants