Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Exceptions/E/exceptions-1.e
Normal file
15
Task/Exceptions/E/exceptions-1.e
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
def nameOf(arg :int) {
|
||||
if (arg == 43) {
|
||||
return "Bob"
|
||||
} else {
|
||||
throw("Who?")
|
||||
}
|
||||
}
|
||||
|
||||
def catching(arg) {
|
||||
try {
|
||||
return ["ok", nameOf(arg)]
|
||||
} catch exceptionObj {
|
||||
return ["notok", exceptionObj]
|
||||
}
|
||||
}
|
||||
8
Task/Exceptions/E/exceptions-2.e
Normal file
8
Task/Exceptions/E/exceptions-2.e
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
? catching(42)
|
||||
# value: ["not ok", problem: Who?]
|
||||
|
||||
? catching(43)
|
||||
# value: ["ok", "Bob"]
|
||||
|
||||
? catching(45.7)
|
||||
# value: ["not ok", problem: the float64 45.7 doesn't coerce to an int]
|
||||
15
Task/Exceptions/E/exceptions-3.e
Normal file
15
Task/Exceptions/E/exceptions-3.e
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
def nameOf(arg :int, ejector) {
|
||||
if (arg == 43) {
|
||||
return "Bob"
|
||||
} else {
|
||||
ejector("Who?")
|
||||
}
|
||||
}
|
||||
|
||||
def catching(arg) {
|
||||
escape unnamed {
|
||||
return ["ok", nameOf(arg, unnamed)]
|
||||
} catch exceptionObj {
|
||||
return ["notok", exceptionObj]
|
||||
}
|
||||
}
|
||||
8
Task/Exceptions/E/exceptions-4.e
Normal file
8
Task/Exceptions/E/exceptions-4.e
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
? catching(42)
|
||||
# value: ["not ok", problem: Who?]
|
||||
|
||||
? catching(43)
|
||||
# value: ["ok", "Bob"]
|
||||
|
||||
? catching(45.7)
|
||||
# problem: the float64 45.7 doesn't coerce to an int
|
||||
11
Task/Exceptions/E/exceptions-5.e
Normal file
11
Task/Exceptions/E/exceptions-5.e
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
var nameTable := null
|
||||
def nameOf(arg :int, ejector) {
|
||||
if (nameTable == null) {
|
||||
nameTable := <import:nameTableParser>.parseFile(<file:nameTable.txt>)
|
||||
}
|
||||
if (nameTable.maps(arg)) {
|
||||
return nameTable[arg]
|
||||
} else {
|
||||
ejector(makeNotFoundException("Who?"))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue