Custom exception was ignored when exc was specified in retry function