Skip to content

Properties that throw exceptions are not handled #45

@Arithmomaniac

Description

@Arithmomaniac

If PublicFieldsAndPropertiesHarvester is used, and a property access attempt throws an exception, the exception bubbles up to the top and cannot be handled, as in the code below.

It would be better to at least allow the user to have the exception returned as the value for that property instead.

System.Reflection.TargetInvocationException occurred
  HResult=-2146232828
  Message=Exception has been thrown by the target of an invocation.
  Source=mscorlib
  StackTrace:
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
       at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
       at StatePrinter.FieldHarvesters.HarvestHelper.<>c__DisplayClass9.<GetFieldsAndProperties>b__6(Object o)
       at StatePrinter.Introspection.IntroSpector.IntrospectComplexType(Object source, Field field, Type sourceType)
       at StatePrinter.Introspection.IntroSpector.Introspect(Object source, Field field)
       at StatePrinter.Introspection.IntroSpector.PrintObject(Object objectToPrint, String rootname)
       at StatePrinter.Stateprinter.PrintObject(Object objectToPrint, String rootname)
  InnerException: 
       HResult=-2146233088
       Message=An identifier field is not present in this artifact's field collection.
       Source=kCura.Relativity.Client
       StackTrace:
            at MyApplication.DTOs.Artifact.get_TextIdentifier()
       InnerException: 

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions