Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
window.addEventListener('unhandledrejection', event => {
if (process.env.NODE_ENV !== 'production')
// eslint-disable-next-line no-console
console.warn(
'An uncaught promise has been rejected and not properly ' +
'handled. This is most likely a bug in the software. Please ensure ' +
'that the promise is correctly handled.'
);
dispatch(
showUnexpectedErrorNotification({ error: { message: event.reason } })
);
});
// If an error has been dispatched already, we don't do anything else.
// If an error has been dispatched already but the query does not contain an error anymore,
// we remove the entry from the dispatchedErrors map.
// If an error has not been dispatched yet, we keep track of it and we dispatch it.
const queryResult = this.props[name];
if (queryResult) {
const hasPreviouslyDispatchedError = Boolean(
this.dispatchedErrors.get(name)
);
const hasQueryErrored = Boolean(queryResult.error);
if (hasPreviouslyDispatchedError && !hasQueryErrored) {
this.dispatchedErrors.delete(name);
}
if (!hasPreviouslyDispatchedError && hasQueryErrored) {
this.dispatchedErrors.set(name, queryResult.error);
this.context.store.dispatch(handleActionError(queryResult.error));
}
}
});
}
Sdk.Get.errorHandler = error =>
globalActions.handleActionError(error, 'sdk')(dispatch);
}}
Sdk.Get.errorHandler = error =>
globalActions.handleActionError(error, 'sdk')(dispatch);
}}
window.addEventListener('error', errorEvent => {
internalReduxStore.dispatch(
showUnexpectedErrorNotification({ error: errorEvent })
);
});
}
showNotification: PropTypes.func.isRequired,
removeNotification: PropTypes.func.isRequired,
showApiErrorNotification: PropTypes.func.isRequired,
showUnexpectedErrorNotification: PropTypes.func.isRequired,
};
NotificationsFaC.displayName = 'NotificationsFaC';
const NotificationsConnector = connect(
(state, ownProps) => {
const notificationsByDomain = selectNotificationsByDomain(state);
return { notifications: notificationsByDomain[ownProps.domain] };
},
{
removeNotification,
showNotification: globalActions.showNotification,
showApiErrorNotification: globalActions.showApiErrorNotification,
showUnexpectedErrorNotification:
globalActions.showUnexpectedErrorNotification,
}
)(NotificationsFaC);
export default NotificationsConnector;
notifications: PropTypes.array.isRequired,
showNotification: PropTypes.func.isRequired,
removeNotification: PropTypes.func.isRequired,
showApiErrorNotification: PropTypes.func.isRequired,
showUnexpectedErrorNotification: PropTypes.func.isRequired,
};
NotificationsFaC.displayName = 'NotificationsFaC';
const NotificationsConnector = connect(
(state, ownProps) => {
const notificationsByDomain = selectNotificationsByDomain(state);
return { notifications: notificationsByDomain[ownProps.domain] };
},
{
removeNotification,
showNotification: globalActions.showNotification,
showApiErrorNotification: globalActions.showApiErrorNotification,
showUnexpectedErrorNotification:
globalActions.showUnexpectedErrorNotification,
}
)(NotificationsFaC);
export default NotificationsConnector;
const StateMachinesDetails = props => {
const dataLocale = useApplicationContext(context => context.dataLocale);
const dispatch = useDispatch();
const fetcher = React.useCallback(
(...args) => dispatch(fetchStateMachine(...args)),
[dispatch]
);
const showApiErrorNotification = useShowApiErrorNotification();
return (
{({ isLoading, data, error }) => {
if (isLoading) {
return ;
}
if (error) {
return null;
}
return (
const Notifier = (props: Props) => {
const showNotification = globalActions.useShowNotification<
Props & { id: number }
>();
React.useEffect(() => {
const notification = showNotification(
{
id: 0,
domain: props.domain,
kind: props.kind,
text: props.text,
},
isNumber(props.dismissAfter)
? { ...props.meta, dismissAfter: props.dismissAfter }
: props.meta
);
return () => {