add specific exception for content manager / loader errors
This commit is contained in:
parent
340bebe354
commit
c1c1ecdfb7
|
@ -194,6 +194,7 @@
|
|||
<Compile Include="Graphics\Atlas\TextureAtlasLoader.cs" />
|
||||
<Compile Include="ServiceLocatorException.cs" />
|
||||
<Compile Include="ConfigFileException.cs" />
|
||||
<Compile Include="Content\ContentManagementException.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
|
23
Blarg.GameFramework/Content/ContentManagementException.cs
Normal file
23
Blarg.GameFramework/Content/ContentManagementException.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
|
||||
namespace Blarg.GameFramework.Content
|
||||
{
|
||||
public class ContentManagementException : Exception
|
||||
{
|
||||
public ContentManagementException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public ContentManagementException(String message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public ContentManagementException(String message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ namespace Blarg.GameFramework.Content
|
|||
{
|
||||
var loader = GetLoader<T>();
|
||||
if (loader == null)
|
||||
throw new InvalidOperationException("No registered loader for this content type.");
|
||||
throw new ContentManagementException("No registered loader for this content type.");
|
||||
else
|
||||
return loader.Get(name, null);
|
||||
|
||||
|
@ -42,7 +42,7 @@ namespace Blarg.GameFramework.Content
|
|||
{
|
||||
var loader = GetLoader<T>();
|
||||
if (loader == null)
|
||||
throw new InvalidOperationException("No registered loader for this content type.");
|
||||
throw new ContentManagementException("No registered loader for this content type.");
|
||||
else
|
||||
return loader.Get(name, contentParameters);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ namespace Blarg.GameFramework.Content
|
|||
{
|
||||
var loader = GetLoader<T>();
|
||||
if (loader == null)
|
||||
throw new InvalidOperationException("No registered loader for this content type.");
|
||||
throw new ContentManagementException("No registered loader for this content type.");
|
||||
else
|
||||
return loader.Pin(name, null);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ namespace Blarg.GameFramework.Content
|
|||
{
|
||||
var loader = GetLoader<T>();
|
||||
if (loader == null)
|
||||
throw new InvalidOperationException("No registered loader for this content type.");
|
||||
throw new ContentManagementException("No registered loader for this content type.");
|
||||
else
|
||||
return loader.Pin(name, contentParameters);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ namespace Blarg.GameFramework.Content
|
|||
{
|
||||
var loader = GetLoader<T>();
|
||||
if (loader == null)
|
||||
throw new InvalidOperationException("No registered loader for this content type.");
|
||||
throw new ContentManagementException("No registered loader for this content type.");
|
||||
else
|
||||
loader.RemoveAll(removePinnedContent);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ namespace Blarg.GameFramework.Content
|
|||
|
||||
var loader = GetLoader<T>();
|
||||
if (loader == null)
|
||||
throw new InvalidOperationException("No registered loader for this content type.");
|
||||
throw new ContentManagementException("No registered loader for this content type.");
|
||||
else
|
||||
return loader.GetNameOf(content);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace Blarg.GameFramework.Content.Types
|
|||
using (var stream = Framework.FileSystem.Open(fontFilename))
|
||||
{
|
||||
if (stream == null)
|
||||
throw new Exception("Failed to load font file when reloading sprite font.");
|
||||
throw new ContentManagementException("Failed to load font file when reloading sprite font.");
|
||||
|
||||
SpriteFontTrueTypeLoader.Load(Framework.GraphicsDevice, stream, size, font);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ namespace Blarg.GameFramework.Content.Types
|
|||
|
||||
int startOfSize = filename.LastIndexOf(':');
|
||||
if (startOfSize == -1)
|
||||
throw new InvalidOperationException("Font filename does not contain any size information.");
|
||||
throw new ContentManagementException("Font filename does not contain any size information.");
|
||||
|
||||
fontFilename = filename.Substring(0, startOfSize);
|
||||
size = Convert.ToInt32(filename.Substring(startOfSize + 1));
|
||||
|
|
|
@ -45,10 +45,10 @@ namespace Blarg.GameFramework.Content.Types
|
|||
|
||||
var image = LoadImage(file);
|
||||
if (image == null)
|
||||
throw new Exception("Failed to load image when reloading texture.");
|
||||
throw new ContentManagementException("Failed to load image when reloading texture.");
|
||||
|
||||
if (texture.Width != image.Width || texture.Height != image.Height)
|
||||
throw new Exception("Image dimensions have changed since original texture creation.");
|
||||
throw new ContentManagementException("Image dimensions have changed since original texture creation.");
|
||||
|
||||
texture.Update(image, 0, 0);
|
||||
}
|
||||
|
|
Reference in a new issue