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

Properties that throw exceptions are not handled #45

Open
Arithmomaniac opened this issue Oct 12, 2015 · 2 comments
Open

Properties that throw exceptions are not handled #45

Arithmomaniac opened this issue Oct 12, 2015 · 2 comments

Comments

@Arithmomaniac
Copy link

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: 
@kbilsted
Copy link
Owner

Thanks for the report. It is a situation a have not even considered could happen:) feel free to submit a pr

@kbilsted
Copy link
Owner

kbilsted commented Jun 3, 2019

Have you given any thoughts on what to present in the output?

perhaps a general exception filter can be provided so you have a fighting chance of either failing (as the current behavior) or implement your own kind of output given knowledge of the field type.

Your thoughts are welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants