mustang-project / Heisenberg

2 stars 1 forks source link

Location of error is masked by f_error #150

Closed DTHaydon closed 7 years ago

DTHaydon commented 7 years ago

When f_error is used the stack gives:

 error: <<Error Message>>
 quitting...
% Stop encountered: F_ERROR             8 /.../KL14/f_error.pro

<<Error Message>> explains what the error is but within the stack there is no information about which file (or line) caused f_error to be used. This might not be helpful in trying to fix/understand errors.


Since the line: % Stop encountered: F_ERROR 8 /.../KL14/f_error.pro is the same for every error caught by f_error it gives no useful information: line 7 & 8 in f_error could be changed to something like:

stop, '  quitting...'

To give the output:

 error: <<Error Message>>
 quitting...
DTHaydon commented 7 years ago

The second part is addressed in #152. This doesn't fix the main problem of showing where the error occurred.

jmdkastro commented 7 years ago

In principle, the specification of the string argument should indicate where in the code the error was triggered, but I agree that a line number would be useful. Any ideas on how to do this?

DTHaydon commented 7 years ago

the specification of the string argument should indicate where in the code the error was triggered

This isn't really the case:

-----------------------------------------------------------------------------------------------
CLSTATS2d: Wed Mar  8 12:37:49 2017
-----------------------------------------------------------------------------------------------
Filename = ./SR1.00SS0.10GR1.00GS0.10--A20.00W20.00_run/peakid/HS1_hr_079_m33sim_rho_Extended_star_A20.00-W20.00
% READFITS: Now reading 2104 by 2104 array
% READFITS: Now reading 2104 by 2104 array
Contour levels at = 12
Contour levels at = 15
Contour levels at = 19
Contour levels at = 25
Contour levels at = 31
Contour levels at = 39
Contour levels at = 50
Contour levels at = 63
Contour levels at = 79
Contour levels at =100
Contour levels at =125
 error: insufficient number of peaks identified (<<...>>)
 quitting...
% Program caused arithmetic error: Floating divide by 0
% Program caused arithmetic error: Floating underflow
% Program caused arithmetic error: Floating overflow
% Program caused arithmetic error: Floating illegal operand
% Prematurely closing batch file: /.../KL14/kl14.pro.

One might look in clstats2d.pro (given the title of the section) but the f_error is actually called in peaks2d.pro which is never mentioned.

The undesirable option is to move stop to where f_error is called but then defeats the point of f_error but there must be a better way -- i'm testing using "Message"

DTHaydon commented 7 years ago

Using:

;Standard error message

pro f_error,estring
    nstring=n_elements(estring)
    estring(0)='error: '+estring(0)
    for i=0,nstring-1 do print,' '+estring(i)
    MESSAGE,' quitting...'
end

Gives:

-----------------------------------------------------------------------------------------------
CLSTATS2d: Wed Mar  8 13:11:53 2017
-----------------------------------------------------------------------------------------------
Filename = ./SR1.00SS0.10GR1.00GS0.10--A20.00W20.00_run/peakid/HS1_hr_079_m33sim_rho_Extended_star_A20.00-W20.00
% READFITS: Now reading 2104 by 2104 array
% READFITS: Now reading 2104 by 2104 array
Contour levels at = 12
Contour levels at = 15
Contour levels at = 19
Contour levels at = 25
Contour levels at = 31
Contour levels at = 39
Contour levels at = 50
Contour levels at = 63
Contour levels at = 79
Contour levels at =100
Contour levels at =125
 error: insufficient number of peaks identified (nlines)
% F_ERROR:  quitting...
% Execution halted at: F_ERROR             7 /home/Tux/DTHaydon/PROGRAM/IDL_Lib/KL14/f_error.pro
%                      PEAKS2D            16 /home/Tux/DTHaydon/PROGRAM/IDL_Lib/KL14/peaks2d.pro
%                      $MAIN$            575 /home/Tux/DTHaydon/PROGRAM/IDL_Lib/KL14/tuningfork.pro
% Program caused arithmetic error: Floating divide by 0
% Program caused arithmetic error: Floating underflow
% Program caused arithmetic error: Floating overflow
% Program caused arithmetic error: Floating illegal operand

If the error message is attached to the MESSAGE line instead the "quitting..." wouldn't be necessary. The name of the program/function might also want to be changed to something like "KL14_ERROR".

DTHaydon commented 7 years ago

See pull request #156 using message

jmdkastro commented 7 years ago

Addressed by #156.