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="Graphics\Atlas\TextureAtlasLoader.cs" />
|
||||||
<Compile Include="ServiceLocatorException.cs" />
|
<Compile Include="ServiceLocatorException.cs" />
|
||||||
<Compile Include="ConfigFileException.cs" />
|
<Compile Include="ConfigFileException.cs" />
|
||||||
|
<Compile Include="Content\ContentManagementException.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||||
<ItemGroup>
|
<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>();
|
var loader = GetLoader<T>();
|
||||||
if (loader == null)
|
if (loader == null)
|
||||||
throw new InvalidOperationException("No registered loader for this content type.");
|
throw new ContentManagementException("No registered loader for this content type.");
|
||||||
else
|
else
|
||||||
return loader.Get(name, null);
|
return loader.Get(name, null);
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ namespace Blarg.GameFramework.Content
|
||||||
{
|
{
|
||||||
var loader = GetLoader<T>();
|
var loader = GetLoader<T>();
|
||||||
if (loader == null)
|
if (loader == null)
|
||||||
throw new InvalidOperationException("No registered loader for this content type.");
|
throw new ContentManagementException("No registered loader for this content type.");
|
||||||
else
|
else
|
||||||
return loader.Get(name, contentParameters);
|
return loader.Get(name, contentParameters);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ namespace Blarg.GameFramework.Content
|
||||||
{
|
{
|
||||||
var loader = GetLoader<T>();
|
var loader = GetLoader<T>();
|
||||||
if (loader == null)
|
if (loader == null)
|
||||||
throw new InvalidOperationException("No registered loader for this content type.");
|
throw new ContentManagementException("No registered loader for this content type.");
|
||||||
else
|
else
|
||||||
return loader.Pin(name, null);
|
return loader.Pin(name, null);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ namespace Blarg.GameFramework.Content
|
||||||
{
|
{
|
||||||
var loader = GetLoader<T>();
|
var loader = GetLoader<T>();
|
||||||
if (loader == null)
|
if (loader == null)
|
||||||
throw new InvalidOperationException("No registered loader for this content type.");
|
throw new ContentManagementException("No registered loader for this content type.");
|
||||||
else
|
else
|
||||||
return loader.Pin(name, contentParameters);
|
return loader.Pin(name, contentParameters);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ namespace Blarg.GameFramework.Content
|
||||||
{
|
{
|
||||||
var loader = GetLoader<T>();
|
var loader = GetLoader<T>();
|
||||||
if (loader == null)
|
if (loader == null)
|
||||||
throw new InvalidOperationException("No registered loader for this content type.");
|
throw new ContentManagementException("No registered loader for this content type.");
|
||||||
else
|
else
|
||||||
loader.RemoveAll(removePinnedContent);
|
loader.RemoveAll(removePinnedContent);
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ namespace Blarg.GameFramework.Content
|
||||||
|
|
||||||
var loader = GetLoader<T>();
|
var loader = GetLoader<T>();
|
||||||
if (loader == null)
|
if (loader == null)
|
||||||
throw new InvalidOperationException("No registered loader for this content type.");
|
throw new ContentManagementException("No registered loader for this content type.");
|
||||||
else
|
else
|
||||||
return loader.GetNameOf(content);
|
return loader.GetNameOf(content);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace Blarg.GameFramework.Content.Types
|
||||||
using (var stream = Framework.FileSystem.Open(fontFilename))
|
using (var stream = Framework.FileSystem.Open(fontFilename))
|
||||||
{
|
{
|
||||||
if (stream == null)
|
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);
|
SpriteFontTrueTypeLoader.Load(Framework.GraphicsDevice, stream, size, font);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ namespace Blarg.GameFramework.Content.Types
|
||||||
|
|
||||||
int startOfSize = filename.LastIndexOf(':');
|
int startOfSize = filename.LastIndexOf(':');
|
||||||
if (startOfSize == -1)
|
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);
|
fontFilename = filename.Substring(0, startOfSize);
|
||||||
size = Convert.ToInt32(filename.Substring(startOfSize + 1));
|
size = Convert.ToInt32(filename.Substring(startOfSize + 1));
|
||||||
|
|
|
@ -45,10 +45,10 @@ namespace Blarg.GameFramework.Content.Types
|
||||||
|
|
||||||
var image = LoadImage(file);
|
var image = LoadImage(file);
|
||||||
if (image == null)
|
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)
|
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);
|
texture.Update(image, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue