Query about Reset Reason (SYSTEM PANIC)

I am using Particle P1, when code is running sometimes it got reset in between and System.resetReason() it shows RESET_REASON_PANIC: System panic. so i want to know

  1. is there any way to know or i can get any indication somehow that in code at which place or line creating problem?
  2. or can i stop that reset i mean if execution can stuck at same place or line it had problem? i tried with
System.on(reset_pending, on_reset_pending);

but it was just disable reset on firmware update.
anyone can help me. Thanks.

What code have you got in your on_reset_pendign() function?

There is no built in feature that would tell you where the crash happened but you can incorporate your own scheme by updating a retained variable on each successful step and read back after a panic reset what that last successful step was and hone in on the “offending” statement that way.
You sould also check what panic caused the reset (not sure but System.resetReasonData() may help with that).

BTW, double posting isn’t appreciated here - a very similar question was asked by a different account but using the same IP.

If both accounts belong to the same person or two persons callaborating on the same project it’s better to keep common questions in one place.