Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

catching exceptions in ML

Tags:

sml

smlnj

is it possible in ML catch every possible exception? for example if I don't know what exception might be

like image 835
rookie Avatar asked Dec 23 '10 09:12

rookie


People also ask

What is catching an exception?

When an appropriate handler is found, the runtime system passes the exception to the handler. An exception handler is considered appropriate if the type of the exception object thrown matches the type that can be handled by the handler. The exception handler chosen is said to catch the exception.

What catch all exceptions?

Try and Except Statement – Catching all ExceptionsTry and except statements are used to catch and handle exceptions in Python. Statements that can raise exceptions are kept inside the try clause and the statements that handle the exception are written inside except clause.

What happens after catching an exception?

If exception occurs in try block then the rest of the statements inside try block are ignored and the corresponding catch block executes. After catch block, the finally block executes and then the rest of the program.

Where should you catch exceptions?

You should catch the exception when you are in the method that knows what to do. For example, forget about how it actually works for the moment, let's say you are writing a library for opening and reading files. Here, the programmer knows what to do, so they catch the exception and handle it.


1 Answers

The handle statement lets you pattern match exceptions, so you can use something like handle _ to match anything, e.g.

hd [] handle _ => 0
like image 150
Ismail Badawi Avatar answered Nov 13 '22 03:11

Ismail Badawi