add specific exception for errors when parsing config files
This commit is contained in:
parent
c9b6279c2a
commit
340bebe354
|
@ -193,6 +193,7 @@
|
|||
<Compile Include="Graphics\Atlas\JsonTextureAtlasTile.cs" />
|
||||
<Compile Include="Graphics\Atlas\TextureAtlasLoader.cs" />
|
||||
<Compile Include="ServiceLocatorException.cs" />
|
||||
<Compile Include="ConfigFileException.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
|
23
Blarg.GameFramework/ConfigFileException.cs
Normal file
23
Blarg.GameFramework/ConfigFileException.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
|
||||
namespace Blarg.GameFramework
|
||||
{
|
||||
public class ConfigFileException : Exception
|
||||
{
|
||||
public ConfigFileException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public ConfigFileException(String message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public ConfigFileException(String message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,13 +24,12 @@ namespace Blarg.GameFramework.Graphics.Atlas
|
|||
throw new ArgumentNullException("file");
|
||||
|
||||
var reader = new StreamReader(file);
|
||||
|
||||
var definition = JsonConvert.DeserializeObject<JsonTextureAtlasDefinition>(reader.ReadToEnd());
|
||||
|
||||
if (definition.Texture == null)
|
||||
throw new Exception("No texture file specified.");
|
||||
throw new ConfigFileException("No texture file specified.");
|
||||
if (definition.Tiles == null || definition.Tiles.Count == 0)
|
||||
throw new Exception("No tiles defined.");
|
||||
throw new ConfigFileException("No tiles defined.");
|
||||
|
||||
var contentManager = Framework.Services.Get<ContentManager>();
|
||||
if (contentManager == null)
|
||||
|
|
Reference in a new issue