[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[task #16263] Remove all exit() calls within the library
From: |
Mohammad Akhlaghi |
Subject: |
[task #16263] Remove all exit() calls within the library |
Date: |
Sat, 17 Sep 2022 16:42:06 -0400 (EDT) |
URL:
<https://savannah.gnu.org/task/?16263>
Summary: Remove all exit() calls within the library
Project: GNU Astronomy Utilities
Submitter: makhlaghi
Submitted: Sat 17 Sep 2022 09:42:05 PM BST
Should Start On: Sat 17 Sep 2022 12:00:00 AM BST
Should be Finished on: Sat 17 Sep 2022 12:00:00 AM BST
Category: Libraries
Priority: 5 - Normal
Item Group: Enhancement
Status: None
Privacy: Public
Percent Complete: 0%
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Effort: 0.00
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Sat 17 Sep 2022 09:42:05 PM BST By: Mohammad Akhlaghi <makhlaghi>
Currently, when the library functions hit a bad situation, they use the
'error(EXIT_FAILURE, ....)' function to inform the user and abort.
For Gnuastro's own programs (which until now where the main callers of the
library), this was not a problem (and infact they are designed around this!).
But for other callers (like pyGnuastro
<https://github.com/Jash-Shah/pyGnuastro>, this is problematic and will cause
an exit from the whole Python environment!
The way that CFITSIO or WCSLIB deal with this is very good: all their
functions have an 'int *status' argument for various types of reasons it can
crash. After it returns, if 'status!=0', then there was an error.
To fix this problem, we should define a special 'enum' in each header for all
the types of crashes that occur in that header file, and assign the status
element as a macro there. The caller can then check status, and if it isn't 0,
they can call a special function in all libraries (for example
'gal_fits_error_message' for the functions in 'fits.h') to get the complete
message for that particular status code. In the case of `pyGnuastro`, to pass
the message to the user (instead of aborting the whole Python program!).
This bug was reported by Faeze Bidjarchian, while we were testing pyGnuastro.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/task/?16263>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [task #16263] Remove all exit() calls within the library,
Mohammad Akhlaghi <=