Skip to content

Commit 93b289e

Browse files
committed
improved error handling
1 parent 02acac9 commit 93b289e

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
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.10.9] - 2016-07-24
6+
- improved error handling
7+
58
## [0.10.2] - 2016-06-28
69
- rely on core-coderoad@0.5
710
- require newer version of test runners

lib/components/SidePanel/SidePanel.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ var SidePanel = (function (_super) {
3838
),
3939
React.createElement(index_1.Alert, null)));
4040
};
41+
SidePanel.prototype.componentWillMount = function () {
42+
this.startErrorLog();
43+
};
44+
SidePanel.prototype.startErrorLog = function () {
45+
window.onerror = function (message, file, line, column, errorObject) {
46+
column = column || (window.event && window.event.errorCharacter);
47+
var stack = errorObject ? errorObject.stack : null;
48+
var data = {
49+
message: message,
50+
file: file,
51+
line: line,
52+
column: column,
53+
errorStack: stack,
54+
};
55+
return false;
56+
};
57+
};
4158
SidePanel = __decorate([
4259
react_redux_1.connect(function (state) { return ({
4360
isWindowOpen: state.window,

src/components/SidePanel/SidePanel.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,24 @@ export default class SidePanel extends React.Component<{
3737
</section>
3838
);
3939
}
40+
private componentWillMount() {
41+
this.startErrorLog();
42+
}
43+
private startErrorLog() {
44+
window.onerror = (message, file, line, column, errorObject) => {
45+
column = column || (window.event && window.event.errorCharacter);
46+
const stack = errorObject ? errorObject.stack : null;
47+
48+
const data = {
49+
message,
50+
file,
51+
line,
52+
column,
53+
errorStack: stack,
54+
};
55+
56+
// call to server
57+
return false;
58+
};
59+
}
4060
};

0 commit comments

Comments
 (0)