Feature #426
ConvertTo with optional arg to give more helpful error message
Description
The ConvertTo
fn is used extensively in the interface between the C5 interpreter and the CoCoALin fns which actually do the work. To improve readability of this code Anna proposes adding a variant of ConvertTo
which accepts a 2nd arg, being a CoCoA::ErrorInfo
object containing the error which should be thrown if conversion fails (thus allowing more meaningful messages to appear in C5).
Related issues
History
#1 Updated by Anna Maria Bigatti about 10 years ago
- Status changed from New to Feedback
- Assignee set to John Abbott
- Target version set to CoCoALib-0.9953
- % Done changed from 0 to 90
Jon implemented this and forgot to say it?
anyway it is very nice:
code was
long n; if (!IsConvertible(n, NumIndets)) CoCoA_ERROR(ERR::ArgTooBig, "RingQQt"); return RingQQt(n);now is
const ErrorInfo ErrMesg(ERR::ArgTooBig, "RingQQt"); return RingQQt(ConvertTo<long>(NumIndets, ErrMesg));it can be done in a single line, but this is more readable.
Of course this means that we are always creating the error message (instead of only when the error occurs), but I find the code much more readable (therefore maintanable).
#2 Updated by Anna Maria Bigatti about 10 years ago
added example and documentation (cvs-ed)
#3 Updated by Anna Maria Bigatti about 10 years ago
- Target version changed from CoCoALib-0.9953 to CoCoALib-0.99532
#4 Updated by Anna Maria Bigatti about 10 years ago
- Status changed from Feedback to Closed
- % Done changed from 90 to 100
We are all happy about this. Tested and documented. Closing.
#5 Updated by Anna Maria Bigatti about 10 years ago
- Estimated time set to 2.50 h