File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
4
4
5
+ ### [ 3.2.0] ( https://github.com/doesdev/get-scrud/compare/3.1.0...3.2.0 )
6
+
7
+ > 2023-09-18
8
+
9
+ - [ Feature] Add httpCode to custom errors
10
+
5
11
### [ 3.1.0] ( https://github.com/doesdev/get-scrud/compare/3.0.0...3.1.0 )
6
12
7
13
> 2023-07-26
Original file line number Diff line number Diff line change @@ -118,10 +118,13 @@ export default (opts = {}) => {
118
118
const handleError = ( e ) => {
119
119
e = e || { }
120
120
const res = e . response || { }
121
+ const makeError = ( errIn ) => {
122
+ return Object . assign ( new Error ( errIn ) , { httpCode : res . status } )
123
+ }
121
124
122
- if ( ( res . data || { } ) . error ) return reject ( new Error ( res . data . error ) )
123
- if ( res . status === 401 ) return reject ( new Error ( 'Unauthorized' ) )
124
- if ( e . code === 'ECONNRESET' ) return reject ( new Error ( 'Request timeout' ) )
125
+ if ( ( res . data || { } ) . error ) return reject ( makeError ( res . data . error ) )
126
+ if ( res . status === 401 ) return reject ( makeError ( 'Unauthorized' ) )
127
+ if ( e . code === 'ECONNRESET' ) return reject ( makeError ( 'Request timeout' ) )
125
128
126
129
const filteredJson = ( Boolean ( jwt ) && JSON . stringify ( e ) ) || ''
127
130
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " get-scrud" ,
3
- "version" : " 3.1 .0" ,
3
+ "version" : " 3.2 .0" ,
4
4
"description" : " Client for SCRUD style rest APIs" ,
5
5
"main" : " index.js" ,
6
6
"type" : " module" ,
You can’t perform that action at this time.
0 commit comments