WorkManagerSample icon indicating copy to clipboard operation
WorkManagerSample copied to clipboard

Exception management

Open 78fede78 opened this issue 5 years ago • 0 comments

Hi I have to perform a task that could go in exception. starting from your example what is the best practice for handling exceptions?

 public class CalculatorWorker : Worker
    {
        public CalculatorWorker(Context context, WorkerParameters workerParameters) : base(context, workerParameters)
        {
 
        }
        public override Result DoWork()
        {
            var taxReturn = CalculateTaxes();
            Android.Util.Log.Debug("CalculatorWorker", $"Your Tax Return is: {taxReturn}");
            return Result.InvokeSuccess();
        }
 
        public double CalculateTaxes()
        {
            throw new Exception("Exception!!!");
            return 2000;
        }
    }

78fede78 avatar Jan 27 '20 11:01 78fede78