protected Object resolveFallback ( MethodInvocationContext < Object , Object > context , RuntimeException exception ) { if ( exception instanceof NoAvailableServiceException ) { NoAvailableServiceException nase = ( NoAvailableServiceException ) exception ; if ( LOG . isErrorEnabled ( ) ) { LOG . debug ( nase . getMessage ( ) , nase ) ; LOG . error ( "Type [{}] attempting to resolve fallback for unavailable service [{}]" , context . getTarget ( ) . getClass ( ) . getName ( ) , nase . getServiceID ( ) ) ; } } else { if ( LOG . isErrorEnabled ( ) ) { LOG . error ( "Type [" + context . getTarget ( ) . getClass ( ) . getName ( ) + "] executed with error: " + exception . getMessage ( ) , exception ) ; } } Optional < ? extends MethodExecutionHandle < ? , Object > > fallback = findFallbackMethod ( context ) ; if ( fallback . isPresent ( ) ) { MethodExecutionHandle < ? , Object > fallbackMethod = fallback . get ( ) ; try { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Type [{}] resolved fallback: {}" , context . getTarget ( ) . getClass ( ) . getName ( ) , fallbackMethod ) ; } return fallbackMethod . invoke ( context . getParameterValues ( ) ) ; } catch ( Exception e ) { throw new FallbackException ( "Error invoking fallback for type [" + context . getTarget ( ) . getClass ( ) . getName ( ) + "]: " + e . getMessage ( ) , e ) ; } } else { throw exception ; } }
Resolves a fallback for the given execution context and exception .