Skip to content

Commit 9ac2134

Browse files
committed
process response errors for userService
1 parent f663164 commit 9ac2134

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

openam-ui/openam-ui-js-sdk/src/lib/userService.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ class UserService {
7070
"Content-Type": "application/json"
7171
},
7272
})
73+
if(!response.ok) {
74+
const data = await response.json() as AuthError
75+
throw new Error(data.message)
76+
}
7377
return await response.json();
7478
} catch (e) {
7579
if (import.meta.env.MODE === 'development') {
@@ -104,6 +108,10 @@ class UserService {
104108
body: JSON.stringify(dataToUpdate),
105109
}
106110
)
111+
if(!response.ok) {
112+
const data = await response.json() as AuthError
113+
throw new Error(data.message)
114+
}
107115
return await response.json();
108116
}
109117

0 commit comments

Comments
 (0)