AlabamaASRL / asset_asrl

https://alabamaasrl.github.io/asset_asrl/
Apache License 2.0
29 stars 6 forks source link

Adaptive(?) Error Messages #35

Open wgledbetter opened 1 year ago

wgledbetter commented 1 year ago

Any time an error is thrown as a result of evaluating a conditional, the arguments to the conditional should be embedded in the error message.

wgledbe commented 1 year ago

For example,

if (xv != ORows()){
    throw std::invalid_argument("size bad pls fix");
}

vs.

if (xv != ORows()){
    std::string errStr = fmt::format("Dear Sir (or Madam),\n\tI regret to inform you that your GenericODE has internal size inconsistencies. You have told me that the ODE has {} X variables, but the output size of compute is {}. I wish you luck in correcting these issues posthaste.\nRegards,\nA.S.S.E.T.\n\nP.S. You may wish to begin your endeavor in '{}' on line {}.", xv, ORows(), __FILE__, __LINE__);
    someLog.error(errStr);
    throw std::invalid_argument(errStr);
}
jbpezent commented 1 year ago

@wgledbetter Agreed, line numbers are already handled when the exception is thrown to python, but there is alot more information that we could and should provide in the error messages, regarding IO sizes, to help diagnose issues.