diff --git a/packages/netlify-cms-backend-git-gateway/src/implementation.js b/packages/netlify-cms-backend-git-gateway/src/implementation.js index 7e3dfe58..defebdc5 100644 --- a/packages/netlify-cms-backend-git-gateway/src/implementation.js +++ b/packages/netlify-cms-backend-git-gateway/src/implementation.js @@ -256,7 +256,14 @@ export default class GitGateway { .readFile('.gitattributes') .then(getLargeMediaPatternsFromGitAttributesFile) .then(patterns => ({ patterns })) - .catch(err => (err.message.includes('404') ? [] : { err })); + .catch(err => { + if (err.message.includes('404')) { + console.log('This 404 was expected and handled appropriately.'); + return []; + } else { + return { err }; + } + }); return Promise.all([netlifyLargeMediaEnabledPromise, lfsPatternsPromise]).then( ([{ enabled: maybeEnabled }, { patterns, err: patternsErr }]) => { diff --git a/packages/netlify-cms-backend-github/src/API.js b/packages/netlify-cms-backend-github/src/API.js index a4380ee4..a62de887 100644 --- a/packages/netlify-cms-backend-github/src/API.js +++ b/packages/netlify-cms-backend-github/src/API.js @@ -14,7 +14,14 @@ import { const CMS_BRANCH_PREFIX = 'cms'; -const replace404WithEmptyArray = err => (err && err.status === 404 ? [] : Promise.reject(err)); +const replace404WithEmptyArray = err => { + if (err && err.status === 404) { + console.log('This 404 was expected and handled appropriately.'); + return []; + } else { + return Promise.reject(err); + } +}; export default class API { constructor(config) { diff --git a/packages/netlify-cms-backend-github/src/implementation.js b/packages/netlify-cms-backend-github/src/implementation.js index b44b09f2..cc042429 100644 --- a/packages/netlify-cms-backend-github/src/implementation.js +++ b/packages/netlify-cms-backend-github/src/implementation.js @@ -107,7 +107,14 @@ export default class GitHub { headers: { Authorization: `token ${token}` }, }) .then(() => true) - .catch(err => (err && err.status === 404 ? false : Promise.reject(err))); + .catch(err => { + if (err && err.status === 404) { + console.log('This 404 was expected and handled appropriately.'); + return false; + } else { + return Promise.reject(err); + } + }); // wait between polls if (!repoExists) { await new Promise(resolve => setTimeout(resolve, pollDelay)); diff --git a/packages/netlify-cms-core/src/actions/mediaLibrary.js b/packages/netlify-cms-core/src/actions/mediaLibrary.js index 95a00559..f1671842 100644 --- a/packages/netlify-cms-core/src/actions/mediaLibrary.js +++ b/packages/netlify-cms-core/src/actions/mediaLibrary.js @@ -148,7 +148,14 @@ export function loadMedia(opts = {}) { .catch( error => console.error(error) || - dispatch(error.status === 404 ? mediaLoaded() : mediaLoadFailed()), + dispatch(() => { + if (error.status === 404) { + console.log('This 404 was expected and handled appropriately.'); + return mediaLoaded(); + } else { + return mediaLoadFailed(); + } + }), ), ), );