private static Response route ( final Take take , final Fallback fbk , final Request req ) throws IOException { final long start = System . currentTimeMillis ( ) ; Response res ; try { res = TkFallback . wrap ( take . act ( req ) , fbk , req ) ; } catch ( final HttpException ex ) { final Opt < Response > fbres = fbk . route ( TkFallback . fallback ( req , start , ex , ex . code ( ) ) ) ; if ( ! fbres . has ( ) ) { throw new IOException ( String . format ( "There is no fallback available in %s" , fbk . getClass ( ) . getCanonicalName ( ) ) , TkFallback . error ( ex , req , start ) ) ; } res = TkFallback . wrap ( fbres . get ( ) , fbk , req ) ; } catch ( final Throwable ex ) { final Opt < Response > fbres = fbk . route ( TkFallback . fallback ( req , start , ex , HttpURLConnection . HTTP_INTERNAL_ERROR ) ) ; if ( ! fbres . has ( ) ) { throw new IOException ( String . format ( "There is no fallback available for %s in %s" , ex . getClass ( ) . getCanonicalName ( ) , fbk . getClass ( ) . getCanonicalName ( ) ) , TkFallback . error ( ex , req , start ) ) ; } res = TkFallback . wrap ( fbres . get ( ) , fbk , req ) ; } return res ; }
Route this request .