Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spit out error messages when conversions go wrong. Fixes #1655 #1656

Merged
merged 1 commit into from Mar 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 19 additions & 11 deletions MvvmCross/Platform/Platform/Converters/MvxValueConverter.cs
Expand Up @@ -5,11 +5,11 @@
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com

using System;
using System.Globalization;

namespace MvvmCross.Platform.Converters
{
using System;
using System.Globalization;

public abstract class MvxValueConverter
: IMvxValueConverter
{
Expand All @@ -31,10 +31,12 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
{
try
{
return this.Convert((TFrom)value, targetType, parameter, culture);
return Convert((TFrom)value, targetType, parameter, culture);
}
catch (Exception)
catch (Exception e)
{
Mvx.TaggedError("MvxValueConverter",
$"Failed to Convert from {typeof (TFrom)} to {typeof (TTo)} with Exception: {e}");
return MvxBindingConstant.UnsetValue;
}
}
Expand All @@ -48,10 +50,12 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
{
try
{
return this.ConvertBack((TTo)value, targetType, parameter, culture);
return ConvertBack((TTo)value, targetType, parameter, culture);
}
catch (Exception)
catch (Exception e)
{
Mvx.TaggedError("MvxValueConverter",
$"Failed to ConvertBack from {typeof(TTo)} to {typeof(TFrom)} with Exception: {e}");
return MvxBindingConstant.UnsetValue;
}
}
Expand All @@ -69,10 +73,12 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
{
try
{
return this.Convert((TFrom)value, targetType, parameter, culture);
return Convert((TFrom)value, targetType, parameter, culture);
}
catch (Exception)
catch (Exception e)
{
Mvx.TaggedError("MvxValueConverter",
$"Failed to Convert from {typeof(TFrom)} with Exception: {e}");
return MvxBindingConstant.UnsetValue;
}
}
Expand All @@ -86,10 +92,12 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
{
try
{
return this.TypedConvertBack(value, targetType, parameter, culture);
return TypedConvertBack(value, targetType, parameter, culture);
}
catch (Exception)
catch (Exception e)
{
Mvx.TaggedError("MvxValueConverter",
$"Failed to ConvertBack to {typeof(TFrom)} with Exception: {e}");
return MvxBindingConstant.UnsetValue;
}
}
Expand Down