add specific exception class for errors when using the service locator
This commit is contained in:
parent
825cee0dfc
commit
c9b6279c2a
|
@ -192,6 +192,7 @@
|
|||
<Compile Include="Graphics\Atlas\JsonTextureAtlasDefinition.cs" />
|
||||
<Compile Include="Graphics\Atlas\JsonTextureAtlasTile.cs" />
|
||||
<Compile Include="Graphics\Atlas\TextureAtlasLoader.cs" />
|
||||
<Compile Include="ServiceLocatorException.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Blarg.GameFramework.Graphics.Atlas
|
|||
{
|
||||
_contentManager = Framework.Services.Get<ContentManager>();
|
||||
if (_contentManager == null)
|
||||
throw new InvalidOperationException("Could not find ContentManager object.");
|
||||
throw new ServiceLocatorException("Could not find a ContentManager object.");
|
||||
|
||||
_animations = new Dictionary<string, TextureAtlasTileAnimation>();
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Blarg.GameFramework.Graphics.Atlas
|
|||
|
||||
var contentManager = Framework.Services.Get<ContentManager>();
|
||||
if (contentManager == null)
|
||||
throw new InvalidOperationException("Cannot find a ContentManager object.");
|
||||
throw new ServiceLocatorException("Could not find a ContentManager object.");
|
||||
|
||||
string textureFile = definition.Texture;
|
||||
if (!String.IsNullOrEmpty(texturePath))
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Blarg.GameFramework.Graphics.ScreenEffects
|
|||
|
||||
_spriteBatch = Framework.Services.Get<SpriteBatch>();
|
||||
if (_spriteBatch == null)
|
||||
throw new InvalidOperationException("No SpriteBatch object registered with the service locator.");
|
||||
throw new ServiceLocatorException("Could not find a SpriteBatch object.");
|
||||
}
|
||||
|
||||
#region Get / Add / Remove
|
||||
|
|
23
Blarg.GameFramework/ServiceLocatorException.cs
Normal file
23
Blarg.GameFramework/ServiceLocatorException.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
|
||||
namespace Blarg.GameFramework
|
||||
{
|
||||
public class ServiceLocatorException : Exception
|
||||
{
|
||||
public ServiceLocatorException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public ServiceLocatorException(String message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public ServiceLocatorException(String message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in a new issue