Skip to content

Commit

Permalink
Merge branch 'main' into new-folder-contents
Browse files Browse the repository at this point in the history
  • Loading branch information
pnicolli committed May 27, 2024
2 parents c2f870c + 62c31c6 commit 9300758
Show file tree
Hide file tree
Showing 5 changed files with 432 additions and 3 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@


## [11.12.2](https://github.com/RedTurtle/design-comuni-plone-theme/compare/v11.12.1...v11.12.2) (2024-05-27)


### Maintenance

* added more logging for some errors ([73a6d13](https://github.com/RedTurtle/design-comuni-plone-theme/commit/73a6d13969775a0d2e52a8794211154a6f8c4da0))
* updated repository info in package.json ([ac3ae90](https://github.com/RedTurtle/design-comuni-plone-theme/commit/ac3ae90b55b8e293bf7dc46394c4a5b81c8db035))


### Documentation

* updated publiccode ([2a28968](https://github.com/RedTurtle/design-comuni-plone-theme/commit/2a28968d62a3800df080842dfc399f7433050b75))

## [11.12.1](https://github.com/redturtle/design-comuni-plone-theme/compare/v11.12.0...v11.12.1) (2024-05-21)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "design-comuni-plone-theme",
"description": "Volto Theme for Italia design guidelines",
"license": "GPL-v3",
"version": "11.12.1",
"version": "11.12.2",
"main": "src/index.js",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions publiccode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ maintenance:
name: io-Comune - Il sito AgID per Comuni ed Enti Pubblici
platforms:
- web
releaseDate: '2024-05-21'
releaseDate: '2024-05-27'
softwareType: standalone/web
softwareVersion: 11.12.1
softwareVersion: 11.12.2
url: 'https://github.com/italia/design-comuni-plone-theme'
usedBy:
- ASP Comuni Modenesi Area Nord
Expand Down
76 changes: 76 additions & 0 deletions src/customizations/volto/components/theme/Error/Error.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* @module components/theme/Error/Error
* Customization:
* - added logging of errors
*/

import React from 'react';
import loadable from '@loadable/component';
import config from '@plone/volto/registry';

const sentryLibraries = {
Sentry: loadable.lib(
() => import(/* webpackChunkName: "s_entry-browser" */ '@sentry/browser'),
),
};

/**
* Error function.
* @function Error
* @returns {string} Markup of the error page.
*/
const Error = (props) => {
const { views } = config;
const { error } = props;
let FoundView;

// CUSTOMIZATION: added logging of errors
const notifySentry = (error) => {
const loaders = Object.entries(sentryLibraries).map(
([name, Lib]) =>
new Promise((resolve) =>
Lib.load().then((mod) => resolve([name, mod])),
),
);
Promise.all(loaders).then((libs) => {
const libraries = Object.assign(
{},
...libs.map(([name, lib]) => ({ [name]: lib })),
);
libraries.Sentry.captureException(error);
});
};

if (error.status === undefined) {
// For some reason, while development and if CORS is in place and the
// requested resource is 404, it returns undefined as status, then the
// next statement will fail
// eslint-disable-next-line no-console
console.error(
'DEV MODE CORS ERROR in Error component: ',
JSON.stringify(props, null, 2),
);
notifySentry(props);
FoundView = views.errorViews.corsError;
} else {
if (error.status.toString() === 'corsError') {
// eslint-disable-next-line no-console
console.error(
'CORS ERROR in Error component: ',
JSON.stringify(props, null, 2),
);
notifySentry(props);
}
FoundView = views.errorViews[error.status.toString()];
}
if (!FoundView) {
FoundView = views.errorViews['404']; // default to 404
}
return (
<div id="view">
<FoundView {...props} />
</div>
);
};

export default Error;
Loading

0 comments on commit 9300758

Please sign in to comment.