Do something cleverer than throwing NRE in a few places

This commit is contained in:
YoshiRulz 2021-01-09 05:08:09 +10:00
parent e976e0c2ad
commit 979afcb54d
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 5 additions and 3 deletions

View File

@ -53,7 +53,7 @@ namespace BizHawk.Bizware.DirectX
}
}
public IEnumerable<KeyEvent> ProcessHostKeyboards() => KeyInput.Update(_config ?? throw new NullReferenceException("o noes"))
public IEnumerable<KeyEvent> ProcessHostKeyboards() => KeyInput.Update(_config ?? throw new Exception(nameof(ProcessHostKeyboards) + " called before the global config was passed"))
.Concat(IPCKeyInput.Update());
public void UpdateConfig(Config config) => _config = config;

View File

@ -18,7 +18,9 @@ namespace BizHawk.Client.DiscoHawk
public MainDiscoForm()
{
InitializeComponent();
Icon = new Icon(typeof(MainDiscoForm).Assembly.GetManifestResourceStream("BizHawk.Client.DiscoHawk.discohawk.ico") ?? throw new NullReferenceException());
var icoStream = typeof(MainDiscoForm).Assembly.GetManifestResourceStream("BizHawk.Client.DiscoHawk.discohawk.ico");
if (icoStream != null) Icon = new Icon(icoStream);
else Console.WriteLine("couldn't load .ico EmbeddedResource?");
}
private void MainDiscoForm_Load(object sender, EventArgs e)

View File

@ -31,7 +31,7 @@ namespace BizHawk.Common
public static string RenameTempFilenameForDelete(string path)
{
string filename = Path.GetFileName(path);
var dir = Path.GetDirectoryName(path) ?? throw new NullReferenceException();
var dir = Path.GetDirectoryName(path) ?? throw new InvalidOperationException();
if (!filename.StartsWith("biz-"))
{
throw new InvalidOperationException();