Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

app wont now crash when widget fails

  • Loading branch information...
commit a2a13f5667379722bc4f8148a351b6515b145216 1 parent 139f9e4
@Eyjafjallajokull authored
Showing with 19 additions and 6 deletions.
  1. +8 −3 core/widgetmanager.py
  2. +1 −1  public/main.css
  3. +10 −2 public/main.js
View
11 core/widgetmanager.py
@@ -5,7 +5,7 @@
import inspect
import sys
import json
-import time
+import traceback
from core.config import Config
# http://stackoverflow.com/questions/1707709/list-all-the-modules-that-are-part-of-a-python-package
@@ -62,8 +62,13 @@ def collectData(self):
widget.setConfig( installedWidgetConfig['config'] )
except KeyError:
pass
-
- newData.append( widget.collectData() )
+
+ widgetData = None
+ try:
+ widgetData = widget.collectData()
+ except Exception as e:
+ logging.error(str(e)+''.join(traceback.format_stack()))
+ newData.append(widgetData)
found = True
if not found:
raise Exception('Unknown widget found in config.')
View
2  public/main.css
@@ -53,7 +53,7 @@ b { font-weight: bold; }
margin: 5px;
padding: 0;
border: 1px solid #8FAAD9;
- border-radius: 0 0 10px 10px;
+ border-radius: 0 0 4px 4px;
background: #fff;
box-shadow: 0 0 20px -20px #bbb;
}
View
12 public/main.js
@@ -116,7 +116,12 @@ var WidgetManager = {
var widget = WidgetManager.installedWidgets[i];
// This widget might be not registred yet. :(
if (!widget) return;
- widget.render(data[i]);
+ try {
+ widget.render(data[i]);
+ } catch (e) {
+ widget.renderError();
+ console.log(e);
+ }
}
},
error: function(jqXHR, textStatus, errorThrown) {
@@ -219,7 +224,10 @@ var Widget = {
this._$element = $('#widget'+this.instanceId);
}
return this._$element.find(selector);
- }
+ },
+ renderError: function() {
+ this.$('.widget').html('failed to render widget')
+ }
};
Please sign in to comment.
Something went wrong with that request. Please try again.