aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-09-19 16:47:07 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-09-19 16:47:07 +0200
commitb7335b8c1425138601698f2deac8e471b371cbcc (patch)
tree44b882d839540d14bfc7f754aca8344301212342
parent8fc4fda0ce88fccbe40c36be3925237a4bca36d9 (diff)
Throw exception instead of returning false to indicate validation failure
This is consistent with what's done in processor and generator.
-rw-r--r--odb/plugin.cxx34
-rw-r--r--odb/validator.cxx5
-rw-r--r--odb/validator.hxx4
3 files changed, 19 insertions, 24 deletions
diff --git a/odb/plugin.cxx b/odb/plugin.cxx
index 7f01478..fbf1fa0 100644
--- a/odb/plugin.cxx
+++ b/odb/plugin.cxx
@@ -112,36 +112,22 @@ gate_callback (void*, void*)
// Validate, pass 1.
//
- {
- validator v;
- if (!v.validate (*options_, *u, file_, 1))
- r = 1;
- }
+ validator v;
+ v.validate (*options_, *u, file_, 1);
// Process.
//
- if (r == 0)
- {
- processor p;
- p.process (*options_, *u, file_);
- }
+ processor pr;
+ pr.process (*options_, *u, file_);
// Validate, pass 2.
//
- if (r == 0)
- {
- validator v;
- if (!v.validate (*options_, *u, file_, 2))
- r = 1;
- }
+ v.validate (*options_, *u, file_, 2);
// Generate.
//
- if (r == 0)
- {
- generator g;
- g.generate (*options_, *u, file_);
- }
+ generator g;
+ g.generate (*options_, *u, file_);
}
catch (parser::failed const&)
{
@@ -149,6 +135,12 @@ gate_callback (void*, void*)
//
r = 1;
}
+ catch (validator::failed const&)
+ {
+ // Diagnostics has aready been issued.
+ //
+ r = 1;
+ }
catch (processor::failed const&)
{
// Diagnostics has aready been issued.
diff --git a/odb/validator.cxx b/odb/validator.cxx
index 90e6b7e..c12bff0 100644
--- a/odb/validator.cxx
+++ b/odb/validator.cxx
@@ -629,7 +629,7 @@ namespace
};
}
-bool validator::
+void validator::
validate (options const& ops,
semantics::unit& u,
semantics::path const&,
@@ -680,5 +680,6 @@ validate (options const& ops,
unit.dispatch (u);
}
- return valid;
+ if (!valid)
+ throw failed ();
}
diff --git a/odb/validator.hxx b/odb/validator.hxx
index 370e5e0..cb6076a 100644
--- a/odb/validator.hxx
+++ b/odb/validator.hxx
@@ -12,9 +12,11 @@
class validator
{
public:
+ struct failed {};
+
// The first pass is performed before processing. The second -- after.
//
- bool
+ void
validate (options const&,
semantics::unit&,
semantics::path const&,