]> ocean-lang.org Git - ocean-D/blob - Ocean-errors
updates
[ocean-D] / Ocean-errors
1 How to handle errors
2
3 I want things to be able to throw errors - or fail-safe(?)
4
5  arithmetic can over-flow
6  pointer-dereference probably needs explicit tests
7  arbitrary functions might report an error
8
9  I need an easy syntax for catching and a simple semantic for
10  when they aren't caught.
11
12  I could have an 'else' on any simple statement which does error handling
13
14
15 Maybe a type that starts '?' can fail to have a value.
16
17 foo: ?int
18
19  foo = 27/0
20
21  would not trigger an error, but you need
22    if ?foo: print foo; else print "div by zero"
23  to use the value
24
25  Most operators will let an error fall through if it is expected.
26
27  If you want details about the error, you need to declare a type that
28  holds a value or an error.  You then get the error code with foo.err or whatever 
29  you have defined.