Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to put the throws clause in a property declaration?

The compiler complains about this code:

public OdbcVersion odbc_version { set { set_odbc_version_ (value); } }

private void set_odbc_version_ (OdbcVersion value) throws UnixOdbcError {
    if (!succeeded (set_environment_attribute_real (handle, Attribute.ODBC_VERSION, (void *) value, 0))) {
        throw new UnixOdbcError.SET_ENVIRONMENT_ATTRIBUTE ("Could not set environment attribute");
    }
} 

The message is:

/mnt/code/dbdiadesign/src/unixodbc.vala:65.42-65.66: warning: unhandled error `UnixOdbc.UnixOdbcError'

Where do I put the throws clause in a property declaration?

like image 661
Jens Mühlenhoff Avatar asked Sep 03 '25 04:09

Jens Mühlenhoff


1 Answers

You can't throw errors in property getters or setters.

like image 125
apmasell Avatar answered Sep 05 '25 01:09

apmasell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!