Re: [Vala] Can constructors throw errors, cascade?



On Wed, Sep 7, 2011 at 6:02 PM, bsquared <bwcode4u gmail com> wrote:

Being new to both Vala and GObjects I hope you will forgive me if my
questions are obvious.

Is it acceptable for a constructor to throw an error.
ie.

               public ResourceFile.from_file (string rc_filename)  throws
GLib.FileError {
                       string sz_data;
                       if (FileUtils.test (rc_filename,
FileTest.IS_REGULAR)) {
                               if (!FileUtils.get_contents(rc_filename, out
sz_data)) {
                                       throw new GLib.FileError.FAILED
(_("could not load
%s.\n".printf(rc_filename)));
                               }
                               ResourceFile.from_data(sz_data); // Is this
OK to cascade?
                       }
               }


It's this.from_data(sz.data).

See https://live.gnome.org/Vala/Tutorial#Construction

-- 
www.debian.org - The Universal Operating System


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]