# wp-ultimate-post-grid/3.8.0/assets/js/shared/ErrorBoundary.js

WP Ultimate Post Grid, version 3.8.0. 48 lines.

- Page: https://pluginprobe.com/plugins/wp-ultimate-post-grid/3.8.0/code/assets/js/shared/ErrorBoundary.js
- Raw: https://pluginprobe.com/plugins/wp-ultimate-post-grid/3.8.0/raw/assets/js/shared/ErrorBoundary.js
- Modified: 2020-01-24T07:47:12+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-ultimate-post-grid/3.8.0/code/assets/js/shared/ErrorBoundary.js#L10-L20`.

```javascript
import React, { Component, Fragment } from 'react';

import '../../css/admin/shared/error-boundary.scss';

export default class ErrorBoundary extends Component {

    constructor(props) {
        super(props);
        
        this.state = {
            hasError: false,
            error: false,
            info: false,
        }
    }

    componentDidCatch(error, info) {
        this.setState({
            hasError: true,
            error,
            info,
        });
    }

    render() {
        return (
            <Fragment>
                {
                    this.state.hasError
                    ?
                    <div className="wpupg-error-boundary">
                        <p>
                            <strong>Something went wrong</strong><br/>
                            Please contact <a href="mailto:support@bootstrapped.ventures">support@bootstrapped.ventures</a> and send along the following information:</p>
                        <pre>
                            { this.props.module ? `Module: ${ this.props.module }\n` : null }
                            { this.state.error ? `Error: ${ this.state.error.toString() }\n` : null }
                            { this.state.info ? `Stack: ${ this.state.info.componentStack }` : null }
                        </pre>
                    </div>
                    :
                    this.props.children
                }
            </Fragment>
        );
    }
}

```
