Exceptions are no longer a type
They do not implement the Type trait, and so cannot be the type of a field, parameter, sequence, dictionary, or typealias.
Doing so gives this error: "type mismatch: expected a 'type' but found an 'exception' (which isn't a 'type')"
Exceptions can only be defined in Slice1 mode
Defining one in Slice gives:
"exeption 'E' cannot be defined in Slice2 mode""note: exceptions can only be defined in Slice1 mode"
Exception specifications are Slice1 only
This doesn't affect the encoding used by the operation, but writing one in Slice2 mode will give this error:
"exceptions can be only thrown by operations defined in Slice1 mode"
Exception specifications can list multiple exceptions
The syntax is: op() -> A throws (E, F). The commas are required, like with inheritance lists.
As a quirk of the grammar, we also allow op() -> A throws (E), this is treated equivalently to throws E.
throwsmust be followed by at least one exception. Only exceptions can be thrown (this was already true).
AnyException is no longer a keyword.
It's just a normal identifier like anything else.
@throws tags require a type now
Previously the type was optional to accommodate AnyException: @throws: my message.
Now you have to say what is thrown: @throws FooException: my message.
Technical changes
Operation used to have special Throws enum for storing whether it threw Nothing, AnyException, or a Specific exception.
Now Operation just holds exception_specification: Vec<TypeRef<Exception>> which can be empty, or 1 or more exceptions.
Type
trait, and so cannot be the type of a field, parameter, sequence, dictionary, or typealias. Doing so gives this error:"type mismatch: expected a 'type' but found an 'exception' (which isn't a 'type')"
"exeption 'E' cannot be defined in Slice2 mode"
"note: exceptions can only be defined in Slice1 mode"
"exceptions can be only thrown by operations defined in Slice1 mode"
op() -> A throws (E, F)
. The commas are required, like with inheritance lists. As a quirk of the grammar, we also allowop() -> A throws (E)
, this is treated equivalently tothrows E
.throws
must be followed by at least one exception. Only exceptions can be thrown (this was already true).AnyException
is no longer a keyword. It's just a normal identifier like anything else.@throws
tags require a type now Previously the type was optional to accommodateAnyException
:@throws: my message
. Now you have to say what is thrown:@throws FooException: my message
.Technical changes
Operation
used to have specialThrows
enum for storing whether it threw Nothing, AnyException, or a Specific exception. NowOperation
just holdsexception_specification: Vec<TypeRef<Exception>>
which can be empty, or 1 or more exceptions.