Skip to content

Commit 25c9c6f

Browse files
authored
Merge pull request #6383 from topcoder-platform/debug-CMS-error
PROD-2156
2 parents 951be91 + 9c93b21 commit 25c9c6f

File tree

3 files changed

+30
-22
lines changed

3 files changed

+30
-22
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ workflows:
356356
filters:
357357
branches:
358358
only:
359-
- circleci-fix
359+
- debug-CMS-error
360360
# This is alternate dev env for parallel testing
361361
- "build-qa":
362362
context : org-global

src/shared/actions/contentful.js

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getService } from 'services/contentful';
33
import { config, redux } from 'topcoder-react-utils';
44
import { removeTrailingSlash } from 'utils/url';
55
import { menuItemBuilder, target as urlTarget } from 'utils/contentful';
6-
import { services } from 'topcoder-react-lib';
6+
import { services, logger } from 'topcoder-react-lib';
77

88
const ERRMSG_UNKNOWN_TARGET = 'Unknown action target';
99

@@ -91,15 +91,19 @@ async function getContentDone(operationId, contentId, target, preview, spaceName
9191
environment,
9292
});
9393
let content;
94-
switch (target) {
95-
case TARGETS.ASSETS:
96-
content = await service.getAsset(contentId);
97-
break;
98-
case TARGETS.ENTRIES:
99-
content = await service.getEntry(contentId);
100-
break;
101-
default:
102-
throw new Error(ERRMSG_UNKNOWN_TARGET);
94+
try {
95+
switch (target) {
96+
case TARGETS.ASSETS:
97+
content = await service.getAsset(contentId);
98+
break;
99+
case TARGETS.ENTRIES:
100+
content = await service.getEntry(contentId);
101+
break;
102+
default:
103+
throw new Error(ERRMSG_UNKNOWN_TARGET);
104+
}
105+
} catch (e) {
106+
logger.error('getContentDone error', e);
103107
}
104108

105109
return {
@@ -141,15 +145,19 @@ async function queryContentDone(operationId, queryId, target,
141145
environment,
142146
});
143147
let data;
144-
switch (target) {
145-
case TARGETS.ASSETS:
146-
data = await service.queryAssets(query);
147-
break;
148-
case TARGETS.ENTRIES:
149-
data = await service.queryEntries(query);
150-
break;
151-
default:
152-
throw new Error(ERRMSG_UNKNOWN_TARGET);
148+
try {
149+
switch (target) {
150+
case TARGETS.ASSETS:
151+
data = await service.queryAssets(query);
152+
break;
153+
case TARGETS.ENTRIES:
154+
data = await service.queryEntries(query);
155+
break;
156+
default:
157+
throw new Error(ERRMSG_UNKNOWN_TARGET);
158+
}
159+
} catch (e) {
160+
logger.error('queryContentDone error', e);
153161
}
154162

155163
return {

src/shared/reducers/contentful/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ function create(init) {
6060
const spaceName = _.get(payload, 'spaceName') || config.CONTENTFUL.DEFAULT_SPACE_NAME;
6161
const environment = _.get(payload, 'environment') || config.CONTENTFUL.DEFAULT_ENVIRONMENT;
6262
const res = _.get(newState, `${spaceName}.${environment}`);
63-
if (error || !res) {
64-
logger.log('CMS-related error', error, res, `${spaceName}.${environment}`, newState, payload, config.CONTENTFUL.DEFAULT_SPACE_NAME, config.CONTENTFUL.DEFAULT_ENVIRONMENT);
63+
if ((error && payload && payload.sys && payload.sys.id !== 'NotFound') || !res) {
64+
logger.log('CMS-related error', JSON.stringify(action), config.CONTENTFUL.DEFAULT_SPACE_NAME, config.CONTENTFUL.DEFAULT_ENVIRONMENT, JSON.stringify(res), JSON.stringify(newState));
6565
return state;
6666
}
6767
const st = state[spaceName][environment];

0 commit comments

Comments
 (0)