Skip to content

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

@aryoda

Description

@aryoda

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!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions