Skip to content

Conversation

@sanbee
Copy link
Owner

@sanbee sanbee commented Sep 30, 2025

The code in this branch intercept number parsing error from the parser and throw a C++ exception.

Two specializations of the clError class -- clBoolParsingError and clNumParsingError are also defined. These are thrown for error in parsing bool, float or int type values. The exceptions are thrown in interactive as well non-interactive (CLI) modes.

The baseclass ErrorObj is now a derivative of the std::exception class.

The exception generation mechanism is not optimal yet, till I figure out some cmake'ism I don't quite understand.

sanbee and others added 4 commits September 25, 2025 20:33
for keywords of type int, float.

To be consistent, change the name of boolError to clBoolParsingError.
…ion.

CMakeLists.txt: Complied Bison and flex files with C++
SetVar.cc: VerifyVal() now intercepts number parsing errors also.
clError.h: Moved clBoolParsingError type here, and removed boolError.h
callback.cc, clParseVal.cc, isBool.cc: Removed inclusion of boolError.h
@sanbee sanbee requested a review from agawatw September 30, 2025 14:16
@sanbee sanbee marked this pull request as ready for review September 30, 2025 14:17
@preshanth preshanth self-assigned this Sep 30, 2025
@agawatw
Copy link
Collaborator

agawatw commented Oct 1, 2025

Checks that have been done:

  1. I built the latest LibRA ardg/main with this parafeed branch and all LibRA unit tests passed.
  2. I manually tested the roadrunner built with this parafeed, and errors are thrown as expected when
  • a bool argument is given a non-bool value.
  • a float/int argument is given a non-float/int value.

Issues:
Current revision does not handle incorrect input for keywords that have factory supplied options. For example, when gridder=100, roadrunner prints

roadrunner>gridder=100 ###Warning: Value did not match any factory supplied options for keyword "gridder" ###Informational: Valid options are "awphpg" "awproject" roadrunner>inp vis = imagename = datacolumn = sowimageext = complexgrid = 100 imsize = 4000 cell = 0 stokes = I reffreq = 3.0e9 phasecenter = weighting = 100 wprojplanes = 1 gridder = 100
It still sets gridder=100.

@agawatw
Copy link
Collaborator

agawatw commented Oct 1, 2025

The issue mentioned above is probably more of a developer's choice, instead of a bug. For example, I tested this roadrunner with

  1. weighting=wrong and even though parafeed does not throw an error, roadrunner does.
  2. gridder=wrong neither parafeed nor roadrunner threw an error and the run completed successfully.

@sanbee It's up to you to decide how you'd like to handle these incorrect inputs to the keywords. Making parafeed throw an error may be the easiest.

@sanbee
Copy link
Owner Author

sanbee commented Oct 1, 2025

I _think_ parafeed is emitting exceptions (of "Informational" or "Warning" type) for a keyword setting that has factory defined options. That's what roadrunner is capturing and reporting. I'll check and make sure this is the case -- in which case your first comment is covered (parafeed emits exceptions). If the exception type is changed (in the library) to FATAL type, the keyword value won't be changed. This is a parafeed "feature" or design decision -- allow users to hang themselves if they want, but at least give a warning.

Your second comment about setting weighting=wrong I don't see. I just tested roadrunner with this setting and it did report the problem (i.e. parafeed emitted and exception that roadrunner caught and reported as warning). Same with the gridder keyword.

sbhatnag@dhruva>/home/dhruva/disk1/sanjay/Packages/LibRA/libra/install/bin/roadrunner 
vis                  = 
imagename            = 
modelimagename       = 
datacolumn           = 
sowimageext          = 
complexgrid          = 
imsize               = 0
cell                 = 0
stokes               = I
reffreq              = 3.0e9
phasecenter          = 
weighting            = natural
wprojplanes          = 1
gridder              = awphpg
cfcache              = 
mode                 = residual
wbawp                = 1
field                = 
spw                  = *
uvrange              = 
pbcor                = 1
conjbeams            = 1
pblimit              = 0.001
usepointing          = 0
roadrunner>weighting=wrong
###Warning:       Value did not match any factory supplied options for keyword "weighting"
###Informational: Valid options are "natural" "uniform" "briggs" 
roadrunner>gridder=wrong
###Warning:       Value did not match any factory supplied options for keyword "gridder"
###Informational: Valid options are "awphpg" "awproject" 
roadrunner>

parafeed does not issue exceptions in the help=noprompt mode. The reason for it is deeper in the design of the library. Basically, in the CLI mode of the application, parafeed does not have factory setting information. And therefore can't issue exceptions. Having said that, I'll look into what it may take to have the factory setting information also available (to the internals of the library) in this mode as well. Seems useful.

Copy link
Collaborator

@agawatw agawatw left a comment

Choose a reason for hiding this comment

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

Question about parafeed does not issue exceptions in the help=noprompt mode has been addressed and Sanjay will look into how the factory setting information can become available to the internals of the library in this mode at a later time.

The rest of the changes seems good to be merged.

@agawatw agawatw merged commit e402fe5 into master Oct 1, 2025
2 checks passed
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.

5 participants