summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2013-04-12 18:48:14 +0200
committerPetr Vobornik <pvoborni@redhat.com>2013-05-06 16:22:25 +0200
commitf1a83b6fdc949b624e717c23768ed9fbcbf572b6 (patch)
tree2d90c7ed98c275e831a2fac50311b9626bb3073c
parentffeafa6ec2974de5e3f2303fa8ffccf1638e9254 (diff)
downloadfreeipa-f1a83b6fdc949b624e717c23768ed9fbcbf572b6.tar.gz
freeipa-f1a83b6fdc949b624e717c23768ed9fbcbf572b6.tar.xz
freeipa-f1a83b6fdc949b624e717c23768ed9fbcbf572b6.zip
Builder: do not break on expected errors
https://fedorahosted.org/freeipa/ticket/3235
-rw-r--r--install/ui/src/freeipa/_base/Builder.js31
1 files changed, 22 insertions, 9 deletions
diff --git a/install/ui/src/freeipa/_base/Builder.js b/install/ui/src/freeipa/_base/Builder.js
index 464a2c09d..75b1a38d3 100644
--- a/install/ui/src/freeipa/_base/Builder.js
+++ b/install/ui/src/freeipa/_base/Builder.js
@@ -210,6 +210,14 @@ define(['dojo/_base/declare',
var cs = construction_spec,
obj = null;
+ if (!(cs.factory && typeof cs.factory === 'function') &&
+ !(cs.ctor && typeof cs.ctor === 'function')) {
+ throw {
+ error: 'Build error: missing or invalid ctor or factory',
+ spec: cs
+ };
+ }
+
// deep clone to prevent modification of original spec by preops
cs.spec = construct.clone(cs.spec);
@@ -223,15 +231,20 @@ define(['dojo/_base/declare',
this.spec_mod.mod(cs.spec, cs.spec);
this.spec_mod.del_rules(cs.spec);
- if (cs.factory && typeof cs.factory === 'function') {
- obj = cs.factory(cs.spec);
- } else if (cs.ctor && typeof cs.ctor === 'function') {
- obj = new cs.ctor(cs.spec);
- } else {
- throw {
- error: 'Build error: missing or invalid ctor or factory',
- spec: cs
- };
+ try {
+ if (cs.factory) {
+ obj = cs.factory(cs.spec);
+ } else {
+ obj = new cs.ctor(cs.spec);
+ }
+ } catch (e) {
+ if (e.expected) {
+ // expected exceptions thrown by builder just mean that
+ // object is not to be built
+ obj = null;
+ } else {
+ throw e;
+ }
}
obj = this._run_post_ops(this.post_ops, obj, cs.spec, context);