File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 1313import {
1414 getRequest ,
1515 createAction ,
16+ stopLoading ,
1617 authErrorHandler
1718} from "openstack-uicore-foundation/lib/utils/actions" ;
1819import { CODE_200 } from "../utils/constants" ;
@@ -43,8 +44,20 @@ export const setSnackbarMessage = (message) => (dispatch) => {
4344} ;
4445
4546export const snackbarErrorHandler = ( err , res ) => ( dispatch , state ) => {
47+ const errors = err . response ?. body ?. errors ;
48+
49+ if ( Array . isArray ( errors ) && errors . length > 0 ) {
50+ dispatch ( stopLoading ( ) ) ;
51+
52+ return setSnackbarMessage ( {
53+ type : "warning" ,
54+ html : errors . join ( "<br>" ) ,
55+ code : err . status || 0
56+ } ) ( dispatch , state ) ;
57+ }
58+
4659 authErrorHandler ( err , res , setSnackbarMessage ) ( dispatch , state ) ;
47- }
60+ } ;
4861
4962export const snackbarSuccessHandler = ( message ) => ( dispatch , state ) =>
5063 setSnackbarMessage ( { ...message , type : "success" , code : CODE_200 } ) (
You can’t perform that action at this time.
0 commit comments