@@ -121,6 +121,36 @@ describe('Logger', function() {
121121 expect ( logArguments . error_data . length ) . to . eql ( 3004 ) ;
122122 } ) ;
123123
124+ it ( 'should log request/response details for Axios-like error objects' , function ( ) {
125+ const error = new Error ( 'Request failed with status code 500' ) ;
126+ error . isAxiosError = true ;
127+ error . response = {
128+ status : 500 ,
129+ statusText : 'Something horrible happened' ,
130+ data : { useful_detail : 'important info' }
131+ } ;
132+ error . config = {
133+ url : 'http://amazinghost.com/beautiful-path' ,
134+ method : 'get'
135+ } ;
136+
137+ logger . fromError ( 'hi' , error , { details : 'here' } ) ;
138+
139+ const logArguments = JSON . parse ( Logger . config . output . args [ 0 ] ) ;
140+ expect ( logArguments . name ) . to . eql ( 'mongo' ) ;
141+ expect ( logArguments . action ) . to . eql ( 'hi' ) ;
142+ expect ( logArguments . level ) . to . eql ( 50 ) ;
143+
144+ expect ( logArguments . error_name ) . to . eql ( error . name ) ;
145+ expect ( logArguments . error_stack ) . to . eql ( error . stack ) ;
146+ expect ( logArguments . error_message ) . to . eql ( error . message ) ;
147+ expect ( logArguments . request_method ) . to . eql ( error . config . method ) ;
148+ expect ( logArguments . request_url ) . to . eql ( error . config . url ) ;
149+ expect ( logArguments . response_status ) . to . eql ( error . response . status ) ;
150+ expect ( logArguments . response_status_text ) . to . eql ( error . response . statusText ) ;
151+ expect ( logArguments . response_data ) . to . eql ( JSON . stringify ( error . response . data ) ) ;
152+ } ) ;
153+
124154 describe ( '#customError' , function ( ) {
125155 it ( 'should log error as the given severity with action' , function ( ) {
126156 const error = new Error ( 'failed' ) ;
0 commit comments