diff src/implab/di/ActivationError.js @ 0:fc2517695ee1

Initial commit, draft import of existing work
author cin
date Thu, 01 Jun 2017 13:20:03 +0300
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/implab/di/ActivationError.js	Thu Jun 01 13:20:03 2017 +0300
@@ -0,0 +1,39 @@
+define([
+    "../declare"
+], function (declare) {
+    return declare(null, {
+        activationStack: null,
+
+        service: null,
+
+        innerException: null,
+
+        message: null,
+
+        constructor: function (service, activationStack, innerException) {
+            this.message = "Failed to activate the service";
+            this.activationStack = activationStack;
+            this.service = service;
+            this.innerException = innerException;
+        },
+
+        toString: function () {
+            var parts = [this.message];
+            if (this.service)
+                parts.push("when activating: " + this.service.toString());
+
+            if (this.innerException)
+                parts.push("caused by: " + this.innerException.toString());
+
+            if (this.activationStack) {
+                parts.push("at");
+                this.activationStack.forEach(function (x) {
+                    parts.push("    " + x.name + " " +
+                        (x.service ? x.service.toString() : ""));
+                });
+            }
+
+            return parts.join("\n");
+        }
+    });
+});
\ No newline at end of file