Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added better error handling when loading resources #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions js/m.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,16 @@ function processArguments() {
var promise = $.getJSON(argValue).then(function(result) {
return result;
}).then(function(data) {
return URL_ARGUMENTS[arg](data)
try {
return URL_ARGUMENTS[arg](data)
} catch (err) {
console.error('Failed to process JSON after successful fetch for "' + arg +
'" with a value of ' + '"' + argValue + '"', err)
console.debug('Data for "' + arg + '"', data)
}
}).fail(function(error) {
console.error('Failed to fetch JSON for "' + arg + '" with a value of ' +
'"' + argValue + '"')
});
processedArgs[arg] = promise;
} else if (GENERAL_ARGUMENTS[arg] != null) {
Expand All @@ -185,7 +194,8 @@ function processArguments() {
}
return postSetup(mappedResults);
}).catch(function(response) {
console.error('Failed to process all arguments. Please fix the failing argument before continuing.', response)
console.error(response)
throw 'Failed to process all arguments. Please fix the failing argument before continuing.'
});
}

Expand Down Expand Up @@ -231,6 +241,9 @@ function getFormattedLabel(meshOrLandmark) {
}

function setupMeshes(meshes) {
if (meshes === undefined || meshes.length == 0) {
throw 'No Meshes available, nothing to display.'
}
var formattedMeshes = []
meshes.forEach(function (mesh) {
var formattedMesh = {
Expand Down
4 changes: 4 additions & 0 deletions js/m.viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ jQuery(document).ready(function() {

// Render the scene!
ren3d.render();
}).catch(function(error) {
console.error(error)
console.error('Error loading arguments, aborting initialization')
$('#loading h3').html('Unable To Load Resources')
})
})

Expand Down