Metro Nuggets

Bitesized tidbits for building Modern (Metro) apps.

Cimbalino, Debugging, and NotSupportedExceptions

Cimbalino is a great toolkit that supports most of Microsoft’s current platforms (including the new UWP), it has a useful set of services and interfaces that really help make building modern apps on Microsoft platforms a doddle. The way in which it does that is by use of the “bait and switch” approach with its PCL and various platform specific implementations. What this does mean, however, is there may be occasions where a service method may not be supported for a specific platform, at this point, Cimbalino will throw a NotSupportedException. The problem with doing this is you may have your logic in a PCL and using Dependency Injection using Cimbalino’s services; your viewmodels may not need to know, or care, about whether a platform supports a particular call, but having that call may crash your app. So what then?

The Solution

One solution to this would be to wrap each Cimbalino service method in a try/catch and catch the NotSupportException, but this isn’t really the desirable approach.

Starting with version 2.0 of the toolkit (out in beta now), there is a new DebugOption that you can set if you want to see those exceptions.

DebugOptions.ThrowNotSupportedExceptions = true;

Now, by default, this is off, so just adding Cimbalino to your app won’t cause any unexpected crashes from an unsupported service call on your platform of choice. However, if you want to know where your app will lack functionality, you can turn this debug option on; then you can crash your app to your heart’s content (or at least until you’ve found where any expected functionality won’t work).

SL

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: