Skip to content

Commit 13c44e9

Browse files
Merge pull request #131 from mh7777777/setError
Handle datastore fetch error.
2 parents 1cb0b95 + e17147e commit 13c44e9

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

control/content/content.controller.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,18 @@
4545

4646
//Go pull any previously saved data
4747
buildfire.datastore.getWithDynamicData(function (err, result) {
48-
if (!err) {
49-
$scope.datastoreInitialized = true;
50-
} else {
51-
console.error("Error: ", err);
52-
return;
48+
if (err || !result) {
49+
console.error(err, 'Error while getting datastore.');
50+
buildfire.dialog.toast({
51+
message: "Error while loading data. Retrying again in 2 seconds...",
52+
duration: 1999
53+
});
54+
setTimeout(() => location.reload(), 2000);
55+
return;
5356
}
5457

58+
$scope.datastoreInitialized = true;
59+
5560
var firstTimeVisit = false;
5661
if (!result.id) {
5762
result.data = Utility.getDefaultScopeData();

control/design/design.controller.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@
1919
});
2020
//Go pull any previously saved data
2121
buildfire.datastore.getWithDynamicData(function (err, result) {
22-
if (!err) {
23-
$scope.datastoreInitialized = true;
24-
} else {
25-
console.error("Error: ", err);
26-
return;
22+
if (err || !result) {
23+
console.error(err, 'Error while getting datastore.');
24+
buildfire.dialog.toast({
25+
message: "Error while loading data. Retrying again in 2 seconds...",
26+
duration: 1999
27+
});
28+
setTimeout(() => location.reload(), 2000);
29+
return;
2730
}
2831

32+
$scope.datastoreInitialized = true;
33+
2934
if (result && result.data && !angular.equals({}, result.data)) {
3035
$scope.data = result.data;
3136
$scope.id = result.id;

0 commit comments

Comments
 (0)