@@ -47,7 +47,8 @@ export function* createUserSaga({ payload }) {
47
47
yield * triggerWebhook ( { payload : { createdFeatureValue : data } } )
48
48
return data
49
49
} catch ( e ) {
50
- yield put ( updateToast ( true , 'error' ) )
50
+ const errMsg = e ?. response ?. body ?. description || e ?. response ?. text
51
+ yield * errorToast ( errMsg )
51
52
yield put ( createUserResponse ( null ) )
52
53
if ( isFourZeroOneError ( e ) ) {
53
54
const jwt = yield select ( ( state ) => state . authReducer . userinfo_jwt )
@@ -67,7 +68,8 @@ export function* updateUserSaga({ payload }) {
67
68
yield * triggerWebhook ( { payload : { createdFeatureValue : data } } )
68
69
return data
69
70
} catch ( e ) {
70
- yield put ( updateToast ( true , 'error' ) )
71
+ const errMsg = e ?. response ?. body ?. description || e ?. response ?. text
72
+ yield * errorToast ( errMsg )
71
73
yield put ( updateUserResponse ( null ) )
72
74
if ( isFourZeroOneError ( e ) ) {
73
75
const jwt = yield select ( ( state ) => state . authReducer . userinfo_jwt )
@@ -86,7 +88,8 @@ export function* changeUserPasswordSaga({ payload }) {
86
88
yield put ( updateToast ( true , 'success' ) )
87
89
yield put ( changeUserPasswordResponse ( data ) )
88
90
} catch ( e ) {
89
- yield put ( updateToast ( true , 'error' ) )
91
+ const errMsg = e ?. response ?. body ?. description || e ?. response ?. text
92
+ yield * errorToast ( errMsg )
90
93
yield put ( changeUserPasswordResponse ( null ) )
91
94
if ( isFourZeroOneError ( e ) ) {
92
95
const jwt = yield select ( ( state ) => state . authReducer . userinfo_jwt )
@@ -105,7 +108,8 @@ export function* getUsersSaga({ payload }) {
105
108
yield call ( postUserAction , audit )
106
109
return data
107
110
} catch ( e ) {
108
- yield put ( getUserResponse ( null ) )
111
+ const errMsg = e ?. response ?. body ?. description || e ?. response ?. text
112
+ yield * errorToast ( errMsg )
109
113
if ( isFourZeroOneError ( e ) ) {
110
114
const jwt = yield select ( ( state ) => state . authReducer . userinfo_jwt )
111
115
yield put ( getAPIAccessToken ( jwt ) )
@@ -126,7 +130,8 @@ export function* deleteUserSaga({ payload }) {
126
130
yield * triggerWebhook ( { payload : { createdFeatureValue : payload } } )
127
131
return data
128
132
} catch ( e ) {
129
- yield put ( updateToast ( true , 'error' ) )
133
+ const errMsg = e ?. response ?. body ?. description || e ?. response ?. text
134
+ yield * errorToast ( errMsg )
130
135
yield put ( deleteUserResponse ( null ) )
131
136
if ( isFourZeroOneError ( e ) ) {
132
137
const jwt = yield select ( ( state ) => state . authReducer . userinfo_jwt )
@@ -136,6 +141,16 @@ export function* deleteUserSaga({ payload }) {
136
141
}
137
142
}
138
143
144
+ function * errorToast ( errMsg ) {
145
+ yield put (
146
+ updateToast (
147
+ true ,
148
+ 'error' ,
149
+ errMsg
150
+ )
151
+ )
152
+ }
153
+
139
154
export function * watchGetUsers ( ) {
140
155
yield takeEvery ( 'user/getUsers' , getUsersSaga )
141
156
}
0 commit comments