Annotate functions with default return value
@poirigui
Submitted by Guillaume Poirier-Morency Link to original bug (#762377)
Description
As discussed on IRC, it would be important to have the possibility of specifying a return value when an error is thrown.
The GIO stream APIs (read and write) expect '-1' to be returned along with the GError.
http://valadoc.org/#!api=gio-2.0/GLib.OutputStream.write
A CCode annotation would be necessary for functions throwing errors with a C expression:
[CCode (return_value_on_error = "-1")]
public override ssize_t write (uint8[] buffer) throws IOError {
throw new IOError.FAILED ("");
}
That would target C code, because a Vala caller would not be able to obtain the return value.
I might be interesting to consider the possibility of obtaining the return value in a try {} catch construct.