66 < link rel ="stylesheet " type ="text/css " href ="https://raw.githubusercontent.com/twbs/bootstrap/master/dist/css/bootstrap.min.css " />
77 < link rel ="stylesheet " href ="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/styles/default.min.css ">
88 < script src ="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/highlight.min.js "> </ script >
9- < script type ="application/javascript " src ="browser/ toplevel/eid.min.js "> </ script >
9+ < script type ="application/javascript " src ="toplevel/eid.min.js "> </ script >
1010 < style type ="text/css ">
1111 @import url (https://fonts.googleapis.com/css?family=PT+Sans|Source+Code+Pro);
1212 body {
1313 font-family : 'PT Sans' , sans-serif;
14- font-size : 1.3 em ;
14+ font-size : 1 em ;
1515 padding : 1em ;
1616 }
1717 pre , code {
@@ -38,6 +38,7 @@ <h1>ExceptionID.js - showcase</h1>
3838
3939 < h3 > Code:</ h3 >
4040 < pre > < code class ="javascript " id ="code ">
41+ var EidRuntimeException = Eid.exceptions.EidRuntimeException;
4142 try {
4243 // Example entity objects
4344 var users = [];
@@ -61,9 +62,11 @@ <h3>Code:</h3>
6162 EidPreconditions.checkState(false, '20160111:224215', 'A extra message');
6263 } catch(e) {
6364 // Top level of your application
64- log.error(e.toString() + ' - ' + e.stack);
65- // or better save your exceptions!
66- logGateway.put(e, {eid: e.eid});
65+ log.error(e.stack);
66+ if (e instanceof EidRuntimeException) {
67+ // or better save your exceptions!
68+ logGateway.put(e, inspectable({eid: e.eid}));
69+ }
6770 }
6871 </ code > </ pre >
6972 < h3 > Console:</ h3 >
@@ -93,9 +96,21 @@ <h3>Console:</h3>
9396 logentry ( 'ERROR' , message ) ;
9497 }
9598 } ;
99+ var inspectable = function ( obj ) {
100+ obj . toString = function ( ) {
101+ var parts = [ ] ;
102+ for ( var k in obj ) {
103+ if ( obj . hasOwnProperty ( k ) && k !== 'toString' ) {
104+ parts . push ( k . toString ( ) + ': ' + obj [ k ] . toString ( ) ) ;
105+ }
106+ }
107+ return '{ ' + parts . join ( ', ' ) + ' }' ;
108+ } ;
109+ return obj ;
110+ } ;
96111 var logGateway = {
97112 put : function ( ex , extra ) {
98- logentry ( 'INFO' , 'LogzGetewayFake .io sucessfully PUT an exception: `' + ex . toString ( ) + '` with extra data of : `' + JSON . stringify ( extra ) + '`' ) ;
113+ logentry ( 'INFO' , 'FakeLogz .io PUT exception: `' + ex . toString ( ) + '`, payload : `' + extra . toString ( ) + '`' ) ;
99114 }
100115 } ;
101116 var code = document . getElementById ( 'code' ) . textContent ;
0 commit comments