Elm Language Debugging Debug.Crash


Example

case thing of
    Cat ->
        meow
    Bike ->
        ride
    Sandwich ->
        eat
    _ ->
        Debug.crash "Not yet implemented"

You can use Debug.crash when you want the program to fail, typically used when you're in the middle of implementing a case expression. It is not recommended to use Debug.crash instead of using a Maybe or Result type for unexpected inputs, but typically only during the course of development (i.e. you typically wouldn't publish Elm code which uses Debug.crash).

Debug.crash takes one String value, the error message to show when crashing. Note that Elm will also output the name of the module and the line of the crash, and if the crash is in a case expression, it will indicate the value of the case.