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

Replace the implementation of .throw_error() and .throw_warning() #256

Merged
merged 4 commits into from
Sep 20, 2024

Conversation

mcol
Copy link
Contributor

@mcol mcol commented Sep 20, 2024

This adopts the last approach I mentioned in #254. It has some advantages on what we have right now:

  • the function name reported is virtually always correct, as we don't rely on using sys.call() which as we've seen can be fragile
  • the calls to the throwing functions don't need to worry anymore about setting nframe to pick the correct stack frame into which look for the function name
  • the implementation of .throw_error() and .throw_warning() is now straightforward

There is one minor disadvantage:

  • at the start of each function that uses the throwing functions, two extra lines of code need to be added in order to manage the internal stack of function names: I find this bearable given what we are gaining.

The example with subset discussed in #254 now returns:

[get_RLum()] Invalid subset expression, valid terms are: curveType, recordType

which is fine, as subset() is just an S3 method that dispatches to get_RLum() for the actual subsetting.

I've broken this up in several commits for easier review. Only on the last commit we actually switch to the new approach, which means that at all points tests still pass (at least locally).

Fixes #254.

This adds the fn_stack list to .LuminescenceEnv, as well as functions
.set_function_name() and .unset_function_name() that manage it.
…ing functions.

This is in preparation of switching .throw_error() and .throw_warning() to use the
.LuminescenceEnv$fn_stack list, for the moment they still behave as before.
Rather than relying on the parsing of sys.call() and the setting of the correct nframe
value, this uses the most up-to-date function name stored in the .LuminescenceEnv
list.
@RLumSK
Copy link
Member

RLumSK commented Sep 20, 2024

Thanks @mcol: It makes sense and I do agree that this additional lines make sense.

@mcol mcol merged commit 0950f02 into master Sep 20, 2024
9 checks passed
@mcol mcol deleted the issue_254 branch September 20, 2024 08:17
@mcol mcol mentioned this pull request Nov 15, 2024
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

Successfully merging this pull request may close these issues.

.throw_error() and .throw_warning()
2 participants