File tree Expand file tree Collapse file tree 4 files changed +61
-30
lines changed
Expand file tree Collapse file tree 4 files changed +61
-30
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,11 @@ export class Exception extends Component {
1313 } ;
1414
1515 render ( ) {
16- var trace = this . props . Trace . split ( '\n' ) ;
1716 var traceElements ;
1817 if ( this . state . expanded ) {
19- traceElements = trace . map ( ( line , i ) => {
18+ traceElements = this . props . Trace . map ( ( trace , i ) => {
2019 return (
21- < TraceLine key = { i } line = { line } />
20+ < TraceLine key = { i } { ... trace } />
2221 ) ;
2322 } ) ;
2423 traceElements = (
Original file line number Diff line number Diff line change 11import { Component } from 'react/addons' ;
22
3+ import { ExceptionParser } from '../ExceptionParser.js' ;
34import { Exception } from './Exception.js' ;
45
56export class LogEntry extends Component {
7+ constructor ( ) {
8+ super ( ) ;
9+ this . exceptionParser = new ExceptionParser ( ) ;
10+ }
11+
612 render ( ) {
713 if ( this . isException ( ) ) {
8- return this . renderExcetion ( ) ;
14+ return this . renderException ( ) ;
915 } else {
1016 return this . renderBasic ( ) ;
1117 }
@@ -17,14 +23,14 @@ export class LogEntry extends Component {
1723 ) ;
1824 }
1925
20- renderExcetion ( ) {
21- var exceptionData = JSON . parse ( this . props . message . substr ( 10 ) ) ;
26+ renderException ( ) {
27+ var exceptionData = this . exceptionParser . parse ( this . props . message ) ;
2228 return (
2329 < Exception { ...exceptionData } />
2430 ) ;
2531 }
2632
2733 isException ( ) {
28- return this . props . message . substr ( 0 , 12 ) === 'Exception: {' ;
34+ return this . exceptionParser . isException ( this . props . message ) ;
2935 }
3036}
Original file line number Diff line number Diff line change @@ -2,33 +2,13 @@ import {Component} from 'react/addons';
22
33export class TraceLine extends Component {
44 render ( ) {
5- var parts = this . props . line . split ( ' ' ) ;
6- var number = parts . shift ( ) ;
7- var line = parts . join ( ' ' ) ;
8- parts = line . split ( ':' ) ;
9-
10- console . log ( line ) ;
11- if ( parts . length > 1 ) {
12- var fileAndLine = parts . shift ( ) ;
13- line = parts . join ( ' ' ) ;
14- if ( fileAndLine [ 0 ] === '[' ) {
15- lineNumber = false ;
16- file = fileAndLine ;
17- } else {
18- var [ file , lineNumber ] = fileAndLine . split ( '(' , 2 ) ;
19- lineNumber = lineNumber . substr ( 0 , lineNumber . length - 1 ) ;
20- }
21- } else {
22- file = false ;
23- }
24-
255 return (
266 < li >
27- < span className = "file" > { file } </ span >
7+ < span className = "file" > { this . props . file } </ span >
288 < span
29- className = "line" > { lineNumber ? ' - line ' + lineNumber + ': ' : '' }
9+ className = "line" > { this . props . lineNumber ? ' - line ' + this . props . lineNumber + ': ' : '' }
3010 </ span >
31- < span className = "call" > { line } </ span >
11+ < span className = "call" > { this . props . call } </ span >
3212 </ li >
3313 ) ;
3414 }
Original file line number Diff line number Diff line change 1+ export class ExceptionParser {
2+ isException ( logMessage ) {
3+ return logMessage . substr ( 0 , 12 ) === 'Exception: {' ;
4+ }
5+
6+ parse ( logMessage ) {
7+ let data = JSON . parse ( logMessage . substr ( 10 ) ) ;
8+ let traceLines = data . Trace . split ( '\n' ) ;
9+ data . Trace = traceLines . map ( this . parseTraceLine ) ;
10+ return data ;
11+ }
12+
13+ parseTraceLine ( line ) {
14+ let parts = line . split ( ' ' ) ;
15+ let number = parts . shift ( ) ;
16+ let traceData = parts . join ( ' ' ) ;
17+ parts = traceData . split ( ':' ) ;
18+
19+ if ( parts . length > 1 ) {
20+ let file , lineNumber ;
21+ let fileAndLine = parts . shift ( ) ;
22+ let call = parts . join ( ' ' ) ;
23+ if ( fileAndLine [ 0 ] === '[' ) {
24+ lineNumber = false ;
25+ file = fileAndLine ;
26+ } else {
27+ let filePaths = fileAndLine . split ( '(' , 2 ) ;
28+ file = filePaths [ 0 ] ;
29+ lineNumber = filePaths [ 1 ] . substr ( 0 , filePaths [ 1 ] . length - 1 ) ;
30+ }
31+ return {
32+ call : call ,
33+ number : number ,
34+ file : file ,
35+ lineNumber : lineNumber
36+ } ;
37+ } else {
38+ return {
39+ call : traceData ,
40+ number : number ,
41+ file : false ,
42+ lineNumber : false
43+ } ;
44+ }
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments