File tree 4 files changed +15
-3
lines changed 4 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 34
34
"@types/chai" : " ^4.0.4" ,
35
35
"@types/chai-as-promised" : " ^7.1.0" ,
36
36
"@types/chai-things" : " ^0.0.32" ,
37
+ "@types/debug" : " 0.0.30" ,
37
38
"@types/fetch-mock" : " 5.12.2" ,
38
39
"@types/inflected" : " 1.1.29" ,
39
40
"@types/lodash" : " 4.14.92" ,
71
72
"winston" : " ^2.3.1"
72
73
},
73
74
"dependencies" : {
75
+ "debug" : " 3.1.0" ,
74
76
"eventbusjs" : " 0.2.0" ,
75
77
"inflected" : " 2.0.3" ,
76
78
"lodash" : " 4.17.10" ,
Original file line number Diff line number Diff line change 1
1
/* tslint:disable:no-console */
2
+ import { IDebugger } from 'debug'
3
+ const debugFactory = require ( 'debug' )
4
+
5
+ export const debug : IDebugger = debugFactory ( 'jsorm' )
6
+
2
7
export enum LogLevel {
3
8
debug = 1 ,
4
9
info = 2 ,
@@ -35,6 +40,7 @@ export class Logger implements ILogger {
35
40
}
36
41
37
42
debug ( stmt : any ) : void {
43
+ debug ( stmt )
38
44
if ( this . _level <= LogLevel . debug ) {
39
45
console . info ( stmt )
40
46
}
Original file line number Diff line number Diff line change @@ -941,4 +941,4 @@ export const isModelInstance = (arg: any): arg is JSORMBase => {
941
941
return false
942
942
}
943
943
return isModelClass ( arg . constructor . currentClass )
944
- }
944
+ }
Original file line number Diff line number Diff line change @@ -109,9 +109,13 @@ export class Request {
109
109
110
110
let json
111
111
try {
112
- json = await response . json ( )
112
+ json = await response . clone ( ) . json ( )
113
113
} 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 )
115
119
}
116
120
117
121
try {
You can’t perform that action at this time.
0 commit comments