Skip to content

Commit 39901f7

Browse files
committed
Include the value that has caused an exception to SetValueExceptionError class
1 parent b8d0352 commit 39901f7

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/CommandLine/Core/ReflectionExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ private static IEnumerable<Error> SetValue<T>(this SpecificationProperty specPro
9898
}
9999
catch (TargetInvocationException e)
100100
{
101-
return new[] { new SetValueExceptionError(specProp.Specification.FromSpecification(), e.InnerException) };
101+
return new[] { new SetValueExceptionError(specProp.Specification.FromSpecification(), e.InnerException, value) };
102102
}
103103
catch (Exception e)
104104
{
105-
return new[] { new SetValueExceptionError(specProp.Specification.FromSpecification(), e) };
105+
return new[] { new SetValueExceptionError(specProp.Specification.FromSpecification(), e, value) };
106106
}
107107
}
108108

src/CommandLine/Error.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,14 +479,16 @@ internal VersionRequestedError()
479479
/// <summary>
480480
/// Models as error generated when exception is thrown at Property.SetValue
481481
/// </summary>
482-
public sealed class SetValueExceptionError : Error
482+
public sealed class SetValueExceptionError : NamedError
483483
{
484484
private readonly Exception exception;
485+
private readonly object value;
485486

486-
internal SetValueExceptionError(Exception exception)
487-
: base(ErrorType.SetValueExceptionError)
487+
internal SetValueExceptionError(NameInfo nameInfo, Exception exception, object value)
488+
: base(ErrorType.SetValueExceptionError, nameInfo)
488489
{
489490
this.exception = exception;
491+
this.value = value;
490492
}
491493

492494
/// <summary>
@@ -496,5 +498,14 @@ public Exception Exception
496498
{
497499
get { return exception; }
498500
}
501+
502+
/// <summary>
503+
/// The value that had to be set to the property
504+
/// </summary>
505+
public object Value
506+
{
507+
get { return value; }
508+
}
509+
499510
}
500511
}

0 commit comments

Comments
 (0)