Permalink
Browse files

Added InjectorInterfaceConstructionError

More specific error so that extensions can catch and inform the user in
a friendly way. Name is just first 'good enough' thing I thought of -
please suggest improvements.
  • Loading branch information...
1 parent 1b7a9d5 commit c24b1cbf9e91ae2d0fedba0d3b3c18482d193e62 @Stray Stray committed Jul 14, 2012
@@ -31,6 +31,7 @@ package org.swiftsuspenders
import org.swiftsuspenders.typedescriptions.TypeDescription;
import org.swiftsuspenders.utils.TypeDescriptor;
import org.swiftsuspenders.utils.SsInternal;
+ import org.swiftsuspenders.errors.InjectorInterfaceConstructionError;
use namespace SsInternal;
@@ -507,7 +508,7 @@ package org.swiftsuspenders
var description : TypeDescription = _classDescriptor.getDescription(type);
if (!description.ctor)
{
- throw new InjectorError(
+ throw new InjectorInterfaceConstructionError(
"Can't instantiate interface " + getQualifiedClassName(type));
}
const instance : * = description.ctor.createInstance(type, this);
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2012 the original author or authors
+ *
+ * Permission is hereby granted to use, modify, and distribute this file
+ * in accordance with the terms of the license agreement accompanying it.
+ */
+
+package org.swiftsuspenders.errors
+{
+ import org.swiftsuspenders.InjectorError;
+
+ public class InjectorInterfaceConstructionError extends InjectorError
+ {
+ public function InjectorInterfaceConstructionError(message:*="", id:*=0)
+ {
+ super(message, id);
+ }
+ }
+}
@@ -59,6 +59,7 @@ package org.swiftsuspenders
import org.swiftsuspenders.support.types.Interface2;
import org.swiftsuspenders.typedescriptions.TypeDescription;
import org.swiftsuspenders.utils.SsInternal;
+ import org.swiftsuspenders.errors.InjectorInterfaceConstructionError;
use namespace SsInternal;
@@ -570,7 +571,7 @@ package org.swiftsuspenders
injectee1.property == injectee2.property);
}
- [Test(expects="org.swiftsuspenders.InjectorError")]
+ [Test(expects="org.swiftsuspenders.errors.InjectorInterfaceConstructionError")]
public function instantiateThrowsMeaningfulErrorOnInterfaceInstantiation() : void
{
injector.getInstance(Interface);

0 comments on commit c24b1cb

Please sign in to comment.