What is the proposed method for handling exceptions in the MVVMCross application?

We are developing a cross-platform application for iOS, Android and WP7 using the MVVMCross framework, and I miss the method in MvxApplication that I can override, which can serve as a neutral, unhandled platform exception handler (which is called platform-specific).

So the question is, what is the proposed method for handling exceptions in general and during an asynchronous call in the MVVMCross application?

Thanks Attila

+3
source share
1 answer

(!) : . MonoTouch MonoDroid


, , , BestSellers: MvvmCross BestSellers

BestSellers 2 , , , MvvmCross:

  • BaseViewModel ViewModel,
  • " " ViewModels UI, UIAlertViews, Toasts / MessageBoxes.

, BestSellers:

ViewModel - . , :

    public CategoryListViewModel()
    {
        AsyncLoad();
    }

    private void AsyncLoad()
    {
        GeneralAsyncLoad(URL_CATEGORIES, ProcessResult);
    }

GeneralAsyncLoad BaseViewModel:

    protected void GeneralAsyncLoad(string url, Action<Stream> responseStreamHandler)
    {
        try
        {
            IsLoading = true;
            var request = WebRequest.Create(url);
            request.BeginGetResponse((result) => GeneralProcessResponse(request, result, responseStreamHandler), null);
        }
        catch (ThreadAbortException)
        {
            throw;
        }
        // obviously we could do better than catching all `Exception` here!
        catch (Exception exception)
        {
            IsLoading = false;
            ReportError("Sorry - problem seen " + exception.Message);
        }
    }

ReportError - a IErrorReporter.

- . ErrorApplicationObject App.cs

, IErrorSource IErrorReporter.

- :


, , - , - ViewModel BaseViewModel.

+3

All Articles