Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stacktrace line output is cut at column width 80, 120 or similar and important information is missing therefore #61

Open
aryoda opened this issue Dec 4, 2020 · 0 comments

Comments

@aryoda
Copy link
Owner

aryoda commented Dec 4, 2020

Problem description:

If I log an error with eg. tryCatchLog() the stack trace lines are cut at a column width of 80 or similar
which makes it difficult sometimes to identify the error reason easily by looking just at the R code contained in the stack trace:

# options(width = 40)
ERROR [2020-12-04 12:35:14] [ERROR] non-numeric argument to mathematical function
Compact call stack:
  1 tryCatch(tryCatchLog({
  2 tryCatchLog.R#326: tryCatch(withCallingH
  3 tryCatchLog.R#326: withCallingHandlers(e
  4 #5: .handleSimpleError(function (c) 

# options(width = 200)
ERROR [2020-12-04 12:36:13] [ERROR] non-numeric argument to mathematical function
Compact call stack:
  1 tryCatch(tryCatchLog({
  2 tryCatchLog.R#326: tryCatch(withCallingHandlers(expr, condition = cond.handler), ..., finally = finally)
  3 tryCatchLog.R#326: withCallingHandlers(expr, condition = cond.handler)
  4 #5: .handleSimpleError(function (c) 

Reason:

R' internal implementation of creating a stack trace uses the function limitedLabels which cuts lines at a maxwidth of getOption("width") - 5L and "width" is 80 or 120/130 by default (R console vs. RStudio) and may not exceed the value 1000.

tryCatchLog uses a modified implementation of this function but still uses the "width" restriction.

You can change the width on a global level eg. via this code snippet

options(width = 200)

but this then applies to every R function that uses this option and may be an unwanted side effect.

Feature request:

It would be better

  1. to provide and use a separate option like "tryCatchLog.max.stacktrace.width"
  2. with a sensible default, eg. a width of 200.

Credits:

Many thanks to MS-SQL guru HSc for making this proposal!

@aryoda aryoda changed the title Stacktrace output is cut at width 80, 120 or similar per line and important information is missing therefore Stacktrace line output is cut at column width 80, 120 or similar and important information is missing therefore Dec 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant