File tree Expand file tree Collapse file tree 4 files changed +15
-3
lines changed Expand file tree Collapse file tree 4 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 3434 "@types/chai" : " ^4.0.4" ,
3535 "@types/chai-as-promised" : " ^7.1.0" ,
3636 "@types/chai-things" : " ^0.0.32" ,
37+ "@types/debug" : " 0.0.30" ,
3738 "@types/fetch-mock" : " 5.12.2" ,
3839 "@types/inflected" : " 1.1.29" ,
3940 "@types/lodash" : " 4.14.92" ,
7172 "winston" : " ^2.3.1"
7273 },
7374 "dependencies" : {
75+ "debug" : " 3.1.0" ,
7476 "eventbusjs" : " 0.2.0" ,
7577 "inflected" : " 2.0.3" ,
7678 "lodash" : " 4.17.10" ,
Original file line number Diff line number Diff line change 11/* tslint:disable:no-console */
2+ import { IDebugger } from 'debug'
3+ const debugFactory = require ( 'debug' )
4+
5+ export const debug : IDebugger = debugFactory ( 'jsorm' )
6+
27export enum LogLevel {
38 debug = 1 ,
49 info = 2 ,
@@ -35,6 +40,7 @@ export class Logger implements ILogger {
3540 }
3641
3742 debug ( stmt : any ) : void {
43+ debug ( stmt )
3844 if ( this . _level <= LogLevel . debug ) {
3945 console . info ( stmt )
4046 }
Original file line number Diff line number Diff line change @@ -941,4 +941,4 @@ export const isModelInstance = (arg: any): arg is JSORMBase => {
941941 return false
942942 }
943943 return isModelClass ( arg . constructor . currentClass )
944- }
944+ }
Original file line number Diff line number Diff line change @@ -109,9 +109,13 @@ export class Request {
109109
110110 let json
111111 try {
112- json = await response . json ( )
112+ json = await response . clone ( ) . json ( )
113113 } catch ( e ) {
114- throw new ResponseError ( response , "invalid json" , e )
114+ if ( response . body ) {
115+ this . logger . debug ( `Invalid Response JSON: ${ response . text ( ) } ` )
116+ }
117+
118+ throw new ResponseError ( response , `invalid json: ${ json } ` , e )
115119 }
116120
117121 try {
You can’t perform that action at this time.
0 commit comments