Skip to content
Browse files

InjectorMissingMappingError introduced.

  • Loading branch information...
1 parent c24b1cb commit 4ea342ccaa181687d1a0b5374d208a7f683a01eb @Stray Stray committed Jul 14, 2012
View
5 src/org/swiftsuspenders/Injector.as
@@ -32,6 +32,7 @@ package org.swiftsuspenders
import org.swiftsuspenders.utils.TypeDescriptor;
import org.swiftsuspenders.utils.SsInternal;
import org.swiftsuspenders.errors.InjectorInterfaceConstructionError;
+ import org.swiftsuspenders.errors.InjectorMissingMappingError;
use namespace SsInternal;
@@ -313,7 +314,7 @@ package org.swiftsuspenders
var mapping : InjectionMapping = _mappings[mappingId];
if (!mapping)
{
- throw new InjectorError('Error while retrieving an injector mapping: ' +
+ throw new InjectorMissingMappingError('Error while retrieving an injector mapping: ' +
'No mapping defined for dependency ' + mappingId);
}
return mapping;
@@ -362,7 +363,7 @@ package org.swiftsuspenders
}
if (name)
{
- throw new InjectorError('No mapping found for request ' + mappingId
+ throw new InjectorMissingMappingError('No mapping found for request ' + mappingId
+ '. getInstance only creates an unmapped instance if no name is given.');
}
return instantiateUnmapped(type);
View
19 src/org/swiftsuspenders/errors/InjectorMissingMappingError.as
@@ -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 InjectorMissingMappingError extends InjectorError
+ {
+ public function InjectorMissingMappingError(message:*="", id:*=0)
+ {
+ super(message, id);
+ }
+ }
+}
View
3 src/org/swiftsuspenders/typedescriptions/MethodInjectionPoint.as
@@ -15,6 +15,7 @@ package org.swiftsuspenders.typedescriptions
import org.swiftsuspenders.InjectorError;
import org.swiftsuspenders.dependencyproviders.DependencyProvider;
import org.swiftsuspenders.utils.SsInternal;
+ import org.swiftsuspenders.errors.InjectorMissingMappingError;
public class MethodInjectionPoint extends InjectionPoint
{
@@ -68,7 +69,7 @@ package org.swiftsuspenders.typedescriptions
{
break;
}
- throw(new InjectorError(
+ throw(new InjectorMissingMappingError(
'Injector is missing a mapping to handle injection into target "' +
target + '" of type "' + getQualifiedClassName(targetType) + '". \
Target dependency: ' + parameterMappingId +
View
3 src/org/swiftsuspenders/typedescriptions/PropertyInjectionPoint.as
@@ -14,6 +14,7 @@ package org.swiftsuspenders.typedescriptions
import org.swiftsuspenders.InjectorError;
import org.swiftsuspenders.dependencyproviders.DependencyProvider;
import org.swiftsuspenders.utils.SsInternal;
+ import org.swiftsuspenders.errors.InjectorMissingMappingError;
public class PropertyInjectionPoint extends InjectionPoint
{
@@ -43,7 +44,7 @@ package org.swiftsuspenders.typedescriptions
{
return;
}
- throw(new InjectorError(
+ throw(new InjectorMissingMappingError(
'Injector is missing a mapping to handle injection into property "' +
_propertyName + '" of object "' + target + '" with type "' +
getQualifiedClassName(targetType) +
View
7 test/org/swiftsuspenders/InjectorTests.as
@@ -60,6 +60,7 @@ package org.swiftsuspenders
import org.swiftsuspenders.typedescriptions.TypeDescription;
import org.swiftsuspenders.utils.SsInternal;
import org.swiftsuspenders.errors.InjectorInterfaceConstructionError;
+ import org.swiftsuspenders.errors.InjectorMissingMappingError;
use namespace SsInternal;
@@ -455,7 +456,7 @@ package org.swiftsuspenders
injectee.property, value);
}
- [Test(expects="org.swiftsuspenders.InjectorError")]
+ [Test(expects="org.swiftsuspenders.errors.InjectorMissingMappingError")]
public function haltOnMissingInterfaceDependency():void
{
injector.injectInto(new InterfaceInjectee());
@@ -469,7 +470,7 @@ package org.swiftsuspenders
assertThat(injectee.property, isA(Clazz));
}
- [Test(expects="org.swiftsuspenders.InjectorError")]
+ [Test(expects="org.swiftsuspenders.errors.InjectorMissingMappingError")]
public function haltOnMissingNamedDependency():void
{
var injectee:NamedClassInjectee = new NamedClassInjectee();
@@ -537,7 +538,7 @@ package org.swiftsuspenders
Assert.assertTrue(injector.satisfies(Clazz, 'namedClass'));
}
- [Test(expects="org.swiftsuspenders.InjectorError")]
+ [Test(expects="org.swiftsuspenders.errors.InjectorMissingMappingError")]
public function getMappingResponseFailsForUnmappedNamedClass():void
{
injector.getInstance(Clazz, 'namedClass');

0 comments on commit 4ea342c

Please sign in to comment.
Something went wrong with that request. Please try again.