Skip to content

Commit d095bb2

Browse files
Frontend - adjusted prettifyErrors (#3041)
* adjusted prettifyErrors * fix
1 parent de2f393 commit d095bb2

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

frontend/src/utils/api.jsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function prettifyErrors(errorResponse) {
5555
"another_key": ["error", "another error"],
5656
}
5757
*/
58-
if (errorResponse.response?.data?.errors) {
58+
if (Object.keys(errorResponse.response.data?.errors).length > 0) {
5959
const prettyHTMLList = [];
6060
Object.entries(errorResponse.response.data?.errors).forEach(
6161
([errorField, errorItem]) => {
@@ -70,5 +70,20 @@ export function prettifyErrors(errorResponse) {
7070
return <ul>{prettyHTMLList}</ul>;
7171
}
7272

73+
// other types of errors
74+
/**
75+
"errors": [
76+
{
77+
"detail": [
78+
"You are not owner or admin of the organization"
79+
]
80+
}
81+
]
82+
*/
83+
/**
84+
"errors": [
85+
"Config with this parameters already exists"
86+
]
87+
*/
7388
return JSON.stringify(errorResponse.response?.data);
7489
}

0 commit comments

Comments
 (0)