paleolimbot opened a new issue, #34826:
URL: https://github.com/apache/arrow/issues/34826

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   In a number of places we have a pattern where we do:
   
   ```r
   tryCatch(
     something_hard_with_confusing_errors(),
     error = function(e) {
       if (grepl("confusing error", conditionMessage(e)) {
         stop("A better error message")
       } else {
         stop(e)
       }
     }
   )
   ```
   
   When we do this we loose the backtrace of the confusing error (which, 
although confusing to the user, is a better indicator of where the error 
occurred when we try to debug it). In more than one case, inspecting the 
original error has resulted in one of us realizing that the original error was 
not the one we expected. In more than one case it has resulted in one of us (me 
at least) manually editing some code to generate a custom build that prints out 
the original error (as opposed to just running the code).
   
   Since we started doing this, rlang has made it relatively easy to throw a 
"classed error" and to include an original error in the backtrace so that you 
can do:
   
   ```r
   tryCatch(
     something_hard_with_confusing_errors(),
     some_custom_error_class = function(e) {
       abort("A better error message", parent = e)
     }
   }
   ```
   
   If for some reason the original error should really really really not get 
printed, we could inspect the value of REPREX_QUIET or ARROW_R_DEV (such that 
we could suggest that an issue opener set one of them and run their code again 
in the event their data is too big to reprex).
   
   ### Component(s)
   
   R


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to