Commit 60f63019 authored by Andrei Mondoc's avatar Andrei Mondoc
Browse files

catch render exception and show 'Could not render preview' message

parent 3a6da03f
......@@ -272,8 +272,11 @@ class CiviCRM_Gutenberg_Blocks {
$_REQUEST['gid'] = $atts['gid'];
ob_start();
( new CRM_Profile_Page_Router )->run( $args );
try {
( new CRM_Profile_Page_Router )->run( $args );
} catch ( Exception $e ) {
// silence
}
return ob_get_clean();
......@@ -296,10 +299,14 @@ class CiviCRM_Gutenberg_Blocks {
ob_start();
( new CRM_Contribute_Controller_Contribution(
'CiviContribute',
CRM_Core_Action::ADD
) )->run();
try {
( new CRM_Contribute_Controller_Contribution(
'CiviContribute',
CRM_Core_Action::ADD
) )->run();
} catch (Exception $e) {
// silence
}
return ob_get_clean();
......@@ -323,10 +330,14 @@ class CiviCRM_Gutenberg_Blocks {
ob_start();
if ( $atts['action'] == 'register' ) {
( new CRM_Event_Controller_Registration() )->run();
} else {
( new CRM_Event_Page_EventInfo )->run();
try {
if ( $atts['action'] == 'register' ) {
( new CRM_Event_Controller_Registration() )->run();
} else {
( new CRM_Event_Page_EventInfo )->run();
}
} catch ( Exception $e ) {
// silence
}
return ob_get_clean();
......@@ -347,7 +358,11 @@ class CiviCRM_Gutenberg_Blocks {
ob_start();
( new CRM_Contact_Page_View_UserDashBoard() )->run();
try {
( new CRM_Contact_Page_View_UserDashBoard() )->run();
} catch ( Exception $e ) {
// silence
}
return ob_get_clean();
......@@ -569,4 +584,3 @@ function civicrm_gutenberg_blocks() {
add_action( 'plugins_loaded', 'civicrm_gutenberg_blocks' );
......@@ -11,6 +11,7 @@ import ProfileModeControl from './components/ProfileModeControl'
import ModeControl from './components/ModeControl'
import ActionControl from './components/ActionControl'
import ExtraAttributesListControl from './components/ExtraAttributesListControl'
import NoPreview from './components/NoPreview'
const CiviCRMContentBlock = ({ attributes, setAttributes }) => {
const { component, gid, id, mode, action, hijack, extra_attributes } = attributes
......@@ -50,10 +51,11 @@ const CiviCRMContentBlock = ({ attributes, setAttributes }) => {
<HijackControl {...{ hijack, setAttributes }} />
<ExtraAttributesListControl {...{ extra_attributes, setAttributes }} />
</InspectorControls>
<p>{__('CiviCRM content block', 'civicrm')}</p>
<ServerSideRender
block='civicrm/civicrm-content-block'
attributes={attributes}
ErrorResponsePlaceholder={NoPreview}
EmptyResponsePlaceholder={NoPreview}
/>
</>
)
......
import { __ } from '@wordpress/i18n'
const NoPreview = () => <p>{__('Could not render preview.', 'civicrm')}</p>
export default NoPreview
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment