plumed / plumed2

Development version of plumed 2
https://www.plumed.org
GNU Lesser General Public License v3.0
323 stars 269 forks source link

More helpful exception text for Registerbase #1080

Open Iximiel opened 1 month ago

Iximiel commented 1 month ago
Description

I was running some tests on some previous commit (where regtest/clusters/rt-dfg1/config had a wrong module prerequisites instead of plumed_modules="adjmat clusters") and the exception text +++ assertion failed: m.count(key)>0 felt not helpful.

I think that the text +++ assertion failed: m.count(key)>0, Missing key is "KEYNAME" feel a little more helpful. I think these few lines may help at least in doing a git grep KEYNAME in src or a plumed manual KEYNAME to find at least which module has not been loaded.


An maybe we can use #1063 for giving directly that info, I do not know if directly in the register or also in an ad-hoc cltool or in cltools/Manual.cpp


Target release

I would like my code to appear in release 2.10

Type of contribution
Copyright
Tests
GiovanniBussi commented 1 month ago

I agree the error msg is terrible. I tried a stupid input file with AA on a single line.

With v2.9 the error is:

I cannot understand line: AA
Maybe a missing space or a typo?

which we deemed cryptic. Now it is

+++ assertion failed: m.count(key)>0

which I would argue is far worse.

Perhaps can be something like:

Action XXX is not known.

Plus, if XXX is in the ModuleMap:

An Action named XXX is available in module YYY. Please consider installing PLUMED with that module enabled.
Iximiel commented 1 month ago

ok, so the modifications could be

For the text I am going with your proposals

Iximiel commented 1 month ago

Now the output is:

PLUMED: ################################################################################
PLUMED: 
PLUMED: Action "CONTACT_MATRIX" is not known.
PLUMED: An Action named "CONTACT_MATRIX" is available in module "adjmat".
PLUMED: Please consider installing PLUMED with that module enabled.
PLUMED: ################################################################################

When the missing action is in the moduleMap

or

PLUMED: ################################################################################
PLUMED: 
PLUMED: Action "ASD" is not known.
PLUMED: ################################################################################

when the missing action is not in the moduleMap


I set up the exception also for the CLTool, for completion, since plumed notCL will exit already with a clear error message