Errors
iett nu bell Error("…") throws an error (throw). pruvamm { … } e si schiatta (errore) { … } catches it and the program goes on (try/catch); aropp { … } always runs, error or not (finally).
An error nobody catches stops the program: the playground shows it in Neapolitan, with the line of your code.
facc dividi(a, b) {
si (b == 0) {
iett nu bell Error("Nun se divide pe zero!")
}
piglie a / b
}
pruvamm {
stamm a dì(dividi(10, 2))
stamm a dì(dividi(1, 0))
} e si schiatta (errore) {
stamm a dì("Errore:", errore.message)
} aropp {
stamm a dì("Fatto")
}
Output
5
Errore: Nun se divide pe zero!
Fatto