forked from tilemill-project/tilemill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathError.bones
36 lines (30 loc) · 997 Bytes
/
Error.bones
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
view = Backbone.View.extend();
// Override _ensureElement.
view.prototype._ensureElement = function() {
this.el = this.el || $('#page');
};
view.prototype.initialize = function(options) {
_(this).bindAll('render');
// Attempt to handle jqXHR objects.
if (options.responseText) {
try {
options = { content: JSON.parse(options.responseText).message };
} catch(e) {
options = { content: options.responseText };
}
} else if (options.status === 0) {
options = { content: 'No response from server.' };
} else if (typeof options === 'string') {
options = { content: options };
} else if (options instanceof Error) {
options = { content: options.toString() };
}
options = options || {};
options.content = options.content || {};
this.options = options;
this.render();
};
view.prototype.render = function() {
$(this.el).html(templates.Error(this.options));
return this;
};