Skip to content

Commit

Permalink
Merge pull request #5181 from rahwang/sandcastle-error-handling
Browse files Browse the repository at this point in the history
sandcastle 403 error handling
  • Loading branch information
emackey authored Apr 4, 2017
2 parents f26255c + 3bf6d78 commit 0ba0178
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions Apps/Sandcastle/CesiumSandcastle.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ require({
var subtabs = {};
var docError = false;
var galleryError = false;
var notFound = false;
var deferredLoadError = false;
var galleryTooltipTimer;
var activeGalleryTooltipDemo;
var demoTileHeightRule = findCssStyle('.demoTileThumbnail');
Expand Down Expand Up @@ -695,7 +695,7 @@ require({
}

function loadFromGallery(demo) {
notFound = false;
deferredLoadError = false;
document.getElementById('saveAsFile').download = demo.name + '.html';
registry.byId('description').set('value', decodeHTML(demo.description).replace(/\\n/g, '\n'));
registry.byId('label').set('value', decodeHTML(demo.label).replace(/\\n/g, '\n'));
Expand Down Expand Up @@ -806,8 +806,8 @@ require({
if (galleryError) {
appendConsole('consoleError', 'Error loading gallery, please run the build script.', true);
}
if (notFound) {
appendConsole('consoleLog', 'Unable to load demo named ' + queryObject.src.replace('.html', '') + '\n', true);
if (deferredLoadError) {
appendConsole('consoleLog', 'Unable to load demo named ' + queryObject.src.replace('.html', '') + '. Redirecting to HelloWorld.\n', true);
}
}
} else if (Cesium.defined(e.data.log)) {
Expand Down Expand Up @@ -1060,15 +1060,10 @@ require({
url : 'gallery/' + name + '.html',
handleAs : 'text',
error : function(error) {
if (error.status === 404) {
loadFromGallery(gallery_demos[hello_world_index])
.then(function() {
notFound = true;
deferredLoadError = true;
});
} else {
galleryError = true;
appendConsole('consoleError', error, true);
}
}
});
}
Expand Down

0 comments on commit 0ba0178

Please sign in to comment.