How to remove the latest frame in stacktrace?

I wrap sentry commands in another class in order to add some more logic to breadcrumbs, exceptions, and messages. When an error is triggered, the latest frame in the stacktrace points to the wrapper class rather than the actual location of the problem. How do I trim that lastest frame off?

Hello @AlexMcGon, which SDK are you using? There are often options to mark frames as in_app=false which only shows them in the ā€œFull stacktraceā€ view.

I am using react-native sdk

@untitaker My account was put on hold instantly. COuldnt reply till now. React-native sdk

Just reread your question, to be clear, the frame after the latest frame is the actual root of the problem, right? You should be able to just pop off the last frame using before-send:


init({
  beforeSend(event, hint) {
   if(event.exception) {
     if(event.exception.values) {
       event.exception.values[0].frames.pop(); // Or shift
     }
    }
    return event;
  }
});

I am sorry but I think thereā€™s currently no nicer way to do this

Great, that is exactly what I am looking for. I can imagine that a built in method for this would be useful for other people using this library. Thanks

1 Like