Throw more helpful 'FileNotFoundException' instead of 'System.ArgumentException: Parameter is not valid' for missing images.

This commit is contained in:
UnknownShadow200 2015-01-06 11:09:40 +11:00
parent b1690d75ab
commit 7b3794dfbc
2 changed files with 5 additions and 0 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.Drawing;
using System.IO;
using OpenTK;
using OpenTK.Graphics.OpenGL;
@ -18,6 +19,9 @@ namespace ClassicalSharp.GraphicsAPI {
public abstract bool Texturing { set; }
public virtual int LoadTexture( string path ) {
if( !File.Exists( path ) ) {
throw new FileNotFoundException( path + " not found" );
}
using( Bitmap bmp = new Bitmap( path ) ) {
return LoadTexture( bmp );
}

View file

@ -69,6 +69,7 @@ namespace ClassicalSharp {
Exception ex = (Exception)e.ExceptionObject;
MessageBox.Show(
"Oh dear, ClassicalSharp crashed. Crash cause: " + Environment.NewLine +
Environment.NewLine +
ex.GetType().FullName + ": " + ex.Message + Environment.NewLine +
ex.StackTrace + Environment.NewLine +
Environment.NewLine +