Panics are commonly used to terminate a program when it detects a programming error (for example, invalid data passed to a function). It works both on emulator and target. Technically a panic is a call to User::Panic with a supplied panic category name and panic number. You can use the name and number to figure out what went wrong.