문제

By stack, I refer to the output from traceback() upon error condition. How does one 'clear the stack' so one gets 'No traceback available' from traceback()? thanks

도움이 되었습니까?

해결책

It can be done by overwriting the .Traceback variable which is currently stored in the base namespace:

stop("Hammer Time!")
Error: Hammer Time!
traceback()
1: stop("Hammer Time!")
assign(".Traceback",NULL,"package:base")
traceback()
No traceback available

Be warned though:

It is undocumented where .Traceback is stored nor that it is visible, and this is subject to change.

다른 팁

you could always do this

 getOption(showWarnCalls, FALSE)
 getOption(showErrorCalls, FALSE)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top