Skip to content

Conversation

TiborGY
Copy link
Contributor

@TiborGY TiborGY commented Jan 4, 2024

Description

A lot of error exits in libdpd are implemented with exit(1) or equivalent. This makes debugging harder, and results in less informative error messages when a test fails in the CI environment.

This PR modernizes all exit(1) error exits in libdpd into throw PSIEXCEPTION.

User API & Changelog headlines

  • Psi4 now prints more detailed error messages if an error happens in its DPD module

Dev notes & details

  • All exit(1) and exit(PSI_RETURN_FAILURE) calls in libdpd have been replaced with a throw PSIEXCEPTION.

Checklist

  • No new features
  • CI tests are failing only due to libint being in flux

Status

  • Ready for review
  • Ready for merge

Copy link
Member

@susilehtola susilehtola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great change. However, I would propose eliminating the old print statements, since the same information is in the error message.

@TiborGY
Copy link
Contributor Author

TiborGY commented Jan 4, 2024

Great change. However, I would propose eliminating the old print statements, since the same information is in the error message.

I have considered doing that, but I am not entirely comfortable with it because throw PSIEXCEPTION is not perfectly reliable when it comes to delivering the error message to the user. For example see #2997.

Until a reliable solution is found for the error messages getting swallowed up on some platforms, I am reluctant to remove the traditional error messages. But in principle I agree completely.

@TiborGY
Copy link
Contributor Author

TiborGY commented Jan 4, 2024

PS: In #2997 I added the band-aid workaround of printing to stderr for PSIO errors, since those are quite common due to disks getting full and whatnot, but doing that globally in PSIEXCEPTION itself seems inelegant.
Users who are not affected by the missing error message would get the entire stack trace, etc. twice, which would make the already quite noisy error exits worse.

@susilehtola
Copy link
Member

The cause of missing error messages is likely the improper use of exit(). I have prepared a companion pull request to this one to get rid of them.

@susilehtola susilehtola mentioned this pull request Jan 4, 2024
7 tasks
@TiborGY
Copy link
Contributor Author

TiborGY commented Jan 4, 2024

The cause of missing error messages is likely the improper use of exit(). I have prepared a companion pull request to this one to get rid of them.

I think there are two separate issues here. One is the improper use of exit() scattered around the codebase, but I still think that there is a separate issue here where not even throw PSIEXCEPTION(...) is delivering the error message, in certain environments. I think that would still be a problem even if every instance of exit() were to be eradicated from the repo.

In #2970, the part of PSIO that was raising the error was already using throw PSIEXCEPTION(...), it was not calling exit(). Unless removing all of the exit() calls elsewhere from the codebase magically changes how PSIEXCEPTION works, I cannot see how that would fix that.

Copy link
Member

@loriab loriab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks for the cleanup!

@loriab loriab added this pull request to the merge queue Feb 6, 2024
@loriab loriab added this to the Psi4 1.10 milestone Feb 6, 2024
Merged via the queue into psi4:master with commit 39403e6 Feb 6, 2024
@TiborGY TiborGY deleted the dpd_throw branch February 6, 2024 13:36
@loriab loriab mentioned this pull request Jan 8, 2025
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.

3 participants