Testing a crash without the compilation warning

I’m writing a basic scheduler for a set of recurring tasks, and I’m looking to test how the code under test handles when the passed function crashes. To simulate a crash, I figured I could just add a true = false (since this pattern match will always fail). However, in doing so, I’m greeted with a compilation warning

warning: this check/guard will always yield the same result

warning: incompatible types:

    false !~ true

While this warning is obviously correct, it’s kind of annoying, especially since as far as I know, there’s no way to suppress specific warnings like you can with Rust. Is there a better way to deliberately crash my program without emitting a compilation warning?


One way would be to use :erlang.error/1 like :erlang.error(:my_error).

Thanks! This is exactly what I was looking for.