]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Check for unhandled errors in creation methods
authorJürg Billeter <j@bitron.ch>
Sat, 15 Aug 2009 13:50:08 +0000 (15:50 +0200)
committerJürg Billeter <j@bitron.ch>
Sat, 15 Aug 2009 13:50:08 +0000 (15:50 +0200)
Fixes bug 571973.

vala/valacreationmethod.vala

index 8700b05648d9f7363cbe8f3004e58bb83999d23f..3dc1aec8bf4feafcf62a742e8b32581361855d29 100644 (file)
@@ -178,6 +178,21 @@ public class Vala.CreationMethod : Method {
                        return false;
                }
 
+               // check that all errors that can be thrown in the method body are declared
+               if (body != null) {
+                       foreach (DataType body_error_type in body.get_error_types ()) {
+                               bool can_propagate_error = false;
+                               foreach (DataType method_error_type in get_error_types ()) {
+                                       if (body_error_type.compatible (method_error_type)) {
+                                               can_propagate_error = true;
+                                       }
+                               }
+                               if (!can_propagate_error) {
+                                       Report.warning (body_error_type.source_reference, "unhandled error `%s'".printf (body_error_type.to_string()));
+                               }
+                       }
+               }
+
                return !error;
        }
 }