Exemplo n.º 1
0
        public async Task <IErrorSafeResponse <T> > ExecuteAsync <T>(Func <Task <T> > action)
        {
            try
            {
                var value = await action.Invoke();

                return(ErrorSafeResponse.Succeed(value));
            }
            catch (Exception e)
            {
                logger?.Error(e, e.Message);
                return(ErrorSafeResponse.Failed <T>());
            }
        }
Exemplo n.º 2
0
        public async Task <IErrorSafeResponse> ExecuteAsync(Func <Task> action)
        {
            try
            {
                await action.Invoke();

                return(ErrorSafeResponse.Succeed());
            }
            catch (Exception e)
            {
                logger?.Error(e, e.Message);

                return(ErrorSafeResponse.Failed());
            }
        }