Handling out of range error

I write in rust on bare metal, and I would like do catching “index out of bounds” panic. How I can do it?

Check before use or get are the usual ways. Panic creation and capture should generally be avoided in favour of result.

1 Like

But in future I would use code, not controlled by me. I write my own kernel, and I would like catch all panics in submodules. Using “get” for all indexes access is bad solution. Rust compiler produced gcc_except_table section. How do I tell the compiler to create the appropriate tables for handling exceptions in this section?