Skip to content

Commit 56ebe4a

Browse files
committed
improved error handling
1 parent fc71215 commit 56ebe4a

File tree

5 files changed

+77
-0
lines changed

5 files changed

+77
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [0.1.4] - 2016-07-24
6+
- improved error handling
7+
58
## [0.1.0] - 2016-06-23
69
- initial early release

lib/components/SidePanel/SidePanel.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,23 @@ var SidePanel = (function (_super) {
4545
)
4646
));
4747
};
48+
SidePanel.prototype.componentWillMount = function () {
49+
this.startErrorLog();
50+
};
51+
SidePanel.prototype.startErrorLog = function () {
52+
window.onerror = function (message, file, line, column, errorObject) {
53+
column = column || (window.event && window.event.errorCharacter);
54+
var stack = errorObject ? errorObject.stack : null;
55+
var data = {
56+
message: message,
57+
file: file,
58+
line: line,
59+
column: column,
60+
errorStack: stack,
61+
};
62+
return false;
63+
};
64+
};
4865
SidePanel = __decorate([
4966
react_redux_1.connect(function (state) { return ({
5067
windowToggle: state.windowToggle,

lib/components/TopPanel/TopPanel.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@ var TopPanel = (function (_super) {
5252
this.props.pageSet(index);
5353
this.props.editorMarkdownOpen(title, index);
5454
};
55+
TopPanel.prototype.componentWillMount = function () {
56+
this.startErrorLog();
57+
};
58+
TopPanel.prototype.startErrorLog = function () {
59+
window.onerror = function (message, file, line, column, errorObject) {
60+
column = column || (window.event && window.event.errorCharacter);
61+
var stack = errorObject ? errorObject.stack : null;
62+
var data = {
63+
message: message,
64+
file: file,
65+
line: line,
66+
column: column,
67+
errorStack: stack,
68+
};
69+
return false;
70+
};
71+
};
5572
TopPanel = __decorate([
5673
react_redux_1.connect(function (state) { return ({
5774
tutorial: state.tutorial,

src/components/SidePanel/SidePanel.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,24 @@ export default class SidePanel extends React.Component<{
4545
</section>
4646
);
4747
}
48+
private componentWillMount() {
49+
this.startErrorLog();
50+
}
51+
private startErrorLog() {
52+
window.onerror = (message, file, line, column, errorObject) => {
53+
column = column || (window.event && window.event.errorCharacter);
54+
const stack = errorObject ? errorObject.stack : null;
55+
56+
const data = {
57+
message,
58+
file,
59+
line,
60+
column,
61+
errorStack: stack,
62+
};
63+
64+
// call to server
65+
return false;
66+
};
67+
}
4868
};

src/components/TopPanel/TopPanel.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,24 @@ export default class TopPanel extends React.Component<{
6262
this.props.pageSet(index);
6363
this.props.editorMarkdownOpen(title, index);
6464
}
65+
private componentWillMount() {
66+
this.startErrorLog();
67+
}
68+
private startErrorLog() {
69+
window.onerror = (message, file, line, column, errorObject) => {
70+
column = column || (window.event && window.event.errorCharacter);
71+
const stack = errorObject ? errorObject.stack : null;
72+
73+
const data = {
74+
message,
75+
file,
76+
line,
77+
column,
78+
errorStack: stack,
79+
};
80+
81+
// call to server
82+
return false;
83+
};
84+
}
6585
}

0 commit comments

Comments
 (0)