Skip to content

Commit

Permalink
Fix JS ErrorHandling issue 3704 (#3706)
Browse files Browse the repository at this point in the history
  * #3704 Correction of Sentry Handling
  • Loading branch information
OllisGit committed Sep 3, 2020
1 parent 6924746 commit 513a7bf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions AUTHORS.md
Expand Up @@ -123,6 +123,7 @@ date of first contribution):
* [Khoi Pham](https://github.com/osubuu)
* [Federico Nembrini](https://github.com/FedericoNembrini)
* [Uri Shaked](https://github.com/urish)
* [Ollis Git](https://github.com/OllisGit)

OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
[Daid Braam](https://github.com/daid). Parts of its communication layer and
Expand Down
6 changes: 3 additions & 3 deletions src/octoprint/static/js/app/helpers.js
Expand Up @@ -1259,7 +1259,7 @@ function setOnViewModelIf(viewModel, key, value, condition) {

viewModel[key] = value;
} catch (exc) {
if (Sentry) {
if (typeof Sentry !== 'undefined') {
Sentry.captureException(exc);
}
log.error("Error while setting", key, "to", value, "on view model", viewModel.constructor.name, ":", (exc.stack || exc));
Expand All @@ -1277,7 +1277,7 @@ function callViewModelsIf(allViewModels, method, condition, callback) {
try {
callViewModelIf(viewModel, method, condition, callback);
} catch (exc) {
if (Sentry) {
if (typeof Sentry !== 'undefined') {
Sentry.captureException(exc);
}
log.error("Error calling", method, "on view model", viewModel.constructor.name, ":", (exc.stack || exc));
Expand Down Expand Up @@ -1339,7 +1339,7 @@ function callViewModelIf(viewModel, method, condition, callback, raiseErrors) {
callback(viewModel[method], viewModel);
}
} catch (exc) {
if (Sentry) {
if (typeof Sentry !== 'undefined') {
Sentry.captureException(exc);
}
if (raiseErrors) {
Expand Down
12 changes: 6 additions & 6 deletions src/octoprint/static/js/app/main.js
Expand Up @@ -386,7 +386,7 @@ $(function() {
try {
viewModelInstance = _createViewModelInstance(viewModel, viewModelMap, optionalDependencyPass);
} catch (exc) {
if (Sentry) {
if (typeof Sentry !== 'undefined') {
Sentry.captureException(exc);
}
log.error("Error instantiating", viewModel.name, ":", (exc.stack || exc));
Expand Down Expand Up @@ -602,7 +602,7 @@ $(function() {
_.each(allViewModelData, function (viewModelData) {
try {
if (!Array.isArray(viewModelData) || viewModelData.length !== 2) {
if (Sentry) {
if (typeof Sentry !== 'undefined') {
Sentry.captureException(new Error("View model data for" + viewModelData.constructor.name + "has wrong format, expected 2-tuple (viewModel, targets), got:" + viewModelData));
}
log.error("View model data for", viewModelData.constructor.name, "has wrong format, expected 2-tuple (viewModel, targets), got:", viewModelData);
Expand All @@ -624,7 +624,7 @@ $(function() {
try {
callViewModel(viewModel, "onBeforeBinding", undefined, true);
} catch (exc) {
if (Sentry) {
if (typeof Sentry !== 'undefined') {
Sentry.captureException(exc);
}
log.error("Error calling onBeforeBinding on view model", viewModel.constructor.name, ":", (exc.stack || exc));
Expand All @@ -649,7 +649,7 @@ $(function() {
try {
object = $(target);
} catch (exc) {
if (Sentry) {
if (typeof Sentry !== 'undefined') {
Sentry.captureException(exc);
}
log.error("Error while attempting to jquery-fy target", target, "of view model", viewModel.constructor.name, ":", (exc.stack || exc));
Expand Down Expand Up @@ -678,7 +678,7 @@ $(function() {

log.debug("View model", viewModel.constructor.name, "bound to", target);
} catch (exc) {
if (Sentry) {
if (typeof Sentry !== 'undefined') {
Sentry.captureException(exc);
}
log.error("Could not bind view model", viewModel.constructor.name, "to target", target, ":", (exc.stack || exc));
Expand Down Expand Up @@ -718,7 +718,7 @@ $(function() {

viewModelMap["uiStateViewModel"].loading(false);
} catch (exc) {
if (Sentry) {
if (typeof Sentry !== 'undefined') {
Sentry.captureException(exc);
}
viewModelMap["uiStateViewModel"].showLoadingError("Application startup failed.");
Expand Down

0 comments on commit 513a7bf

Please sign in to comment.