Closed saber-wang closed 2 years ago
Hello @saber-wang ,
Thank you for asking,
I can understand the reason when using a nullable type such as bool?
.
Are you looking for a solution only for when the compilation fails (like this case) or also when the execution fails?
Best Regards,
Jon
@JonathanMagnan Thank you for your answer. After reading your answer, I realized that the compilation phase failed. Can I handle it at this stage?
Hello @saber-wang ,
It depends on what you mean by "Can I handle it". What exactly do you want to do?
You can sure handle it with a try/catch but I'm not really sure what you are looking for.
When the compilation fail, the error causing it is raised, and the 2 followings properties are populated:
@JonathanMagnan I don't want to throw an exception here because the object is dynamic.😁
Hello @saber-wang ,
Your current example is an anonymous type, not an expando / dynamic object.
Expando and dynamic object will normally compile without problem but will indeed raise an error when executing if, for example the property in the expression doesn't exists.
@JonathanMagnan That's right. I was negligent. Thanks for your help.
for example:
The following exception will be thrown:
I want to return
default
.