When a call exists of multiple lines, a potential error only includes the first line of match.call() resulting in some lost information and an incomplete sentence. A simple example:
#proper error message:
runif(n=1, k=5)
#incomplete error message:
runif(n=1, k={5})
What would be a way to get R to include the full call to the error message (maybe by collapsing the multiple lines or so)? I am mostly interested in using this in a tryCatch setting.
I had a go at investigating the error object in a
tryCatchsetting via:And then selected the 4th environment (
value[[3]](cond)) to examinee.I noticed that
e$callwas:So it seems that the error message just uses that first line.
You can collapse all the lines together with:
So you could try something like:
But this doesn’t fix up the error message itself, just the call leading up to it:
So the ‘Error in xxx’ is complete, but the ‘unused argument(s) xxx’ is still not. It’s a start, but not all the way there.
I’m not sure how to improve on this (and am also interested to know if it’s possible).