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

v2.0.5 SetImage() broken with the try catch #45

Closed
dgwaldo opened this issue Apr 16, 2024 · 1 comment
Closed

v2.0.5 SetImage() broken with the try catch #45

dgwaldo opened this issue Apr 16, 2024 · 1 comment

Comments

@dgwaldo
Copy link
Contributor

dgwaldo commented Apr 16, 2024

This commit introduced a bug. Getting the variable source on the same line that the cast to (int) is on only works if the variable source returns an index value. I believe it just needs null guarded to work correctly.

After debugging our project locally to see what was going on, I have this relatively simple fix.

 var index = 0;
 try {
     var vsIndex = variableSource.GetVariable("index");
     if (vsIndex != null) {
         index = (int)vsIndex;
     }
 } catch (VariableNotFoundException) {
 }

At first I was confused as to why the try catch, but then I realized that the variable source may not have ThrowIfNotFound set to True. In that case the try catch is very important. However, not sure how, but would be nice to be able to do something like this without the try catch...

In any case, it is a simple fix.

@antonmihaylov
Copy link
Owner

antonmihaylov commented Apr 22, 2024

thanks for the catch and the fix!

However, not sure how, but would be nice to be able to do something like this without the try catch...

I agree, there are better ways to do this especially looking back at it, but at the moment bug fixing is the priority so i merged it and released version 2.0.6 with the fix, it should be available soon in Nuget

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

No branches or pull requests

2 participants