File "wp-error-details.js"

Full Path: /home/siazco/grocery.siazco.se/wp-content/plugins/better-wp-security/core/packages/components/src/site-scan-results/wp-error-details.js
File size: 1.24 KB
MIME-type: text/x-java
Charset: utf-8

/**
 * WordPress dependencies
 */
import { __, sprintf } from '@wordpress/i18n';
import { Fragment } from '@wordpress/element';

/**
 * Internal dependencies
 */
import WrappedSection from './wrapped-section';

function WPErrorDetails( { results, showErrorDetails = false } ) {
	const wpError = results;

	return (
		<WrappedSection
			status="error"
			description={ __(
				'The scan failed to properly scan the site.',
				'better-wp-security'
			) }
		>
			<p>
				{ sprintf(
					/* translators: 1. Error message. */
					__( 'Error Message: %s', 'better-wp-security' ),
					wpError.getErrorMessage()
				) }
			</p>
			<p>
				{ sprintf(
					/* translators: 1. Error code. */
					__( 'Error Code: %s', 'better-wp-security' ),
					wpError.getErrorCode()
				) }
			</p>

			{ showErrorDetails && wpError.getErrorData() && (
				<Fragment>
					<p>
						{ __(
							'If you contact support about this error, please provide the following debug details:',
							'better-wp-security'
						) }
					</p>
					<pre>
						{ JSON.stringify(
							{
								code: wpError.getErrorCode(),
								data: wpError.getErrorData(),
							},
							null,
							2
						) }
					</pre>
				</Fragment>
			) }
		</WrappedSection>
	);
}

export default WPErrorDetails;