mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 06:20:25 +00:00
Added overload to Util.Error to use ErrorWindow
This commit is contained in:
parent
644c0acee3
commit
02ce104425
8 changed files with 39 additions and 16 deletions
|
@ -551,7 +551,7 @@ namespace PKHeX
|
|||
catch (Exception e) { Util.Error("File is in use by another program!", path, e.ToString()); return; }
|
||||
|
||||
try { openFile(input, path, ext); }
|
||||
catch (Exception e) { Util.Error("Unable to load file.", e.ToString()); }
|
||||
catch (Exception e) { Util.Error("Unable to load file.", e); }
|
||||
}
|
||||
}
|
||||
private void openFile(byte[] input, string path, string ext)
|
||||
|
@ -2503,7 +2503,7 @@ namespace PKHeX
|
|||
DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move);
|
||||
}
|
||||
catch (Exception x)
|
||||
{ Util.Error("Drag & Drop Error", x.ToString()); }
|
||||
{ Util.Error("Drag & Drop Error", x); }
|
||||
Cursor = DragInfo.Cursor = DefaultCursor;
|
||||
File.Delete(newfile);
|
||||
}
|
||||
|
@ -2559,7 +2559,7 @@ namespace PKHeX
|
|||
|
||||
try { Directory.CreateDirectory(BackupPath); Util.Alert("Backup folder created!",
|
||||
$"If you wish to no longer automatically back up save files, delete the \"{BackupPath}\" folder."); }
|
||||
catch { Util.Error($"Unable to create backup folder @ {BackupPath}"); }
|
||||
catch(Exception ex) { Util.Error($"Unable to create backup folder @ {BackupPath}", ex); }
|
||||
}
|
||||
private void clickExportSAV(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -3428,7 +3428,7 @@ namespace PKHeX
|
|||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
Util.Error("Drag & Drop Error:", x.ToString());
|
||||
Util.Error("Drag & Drop Error", x);
|
||||
}
|
||||
DragInfo.Reset();
|
||||
Cursor = DefaultCursor;
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace PKHeX.Misc
|
|||
{
|
||||
public partial class ErrorWindow : Form
|
||||
{
|
||||
public static void ShowErrorDialog(string friendlyMessage, Exception ex, bool allowContinue)
|
||||
public static DialogResult ShowErrorDialog(string friendlyMessage, Exception ex, bool allowContinue)
|
||||
{
|
||||
var lang = System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName;
|
||||
var dialog = new ErrorWindow(lang);
|
||||
|
@ -24,6 +24,7 @@ namespace PKHeX.Misc
|
|||
{
|
||||
Application.Exit();
|
||||
}
|
||||
return dialogResult;
|
||||
}
|
||||
|
||||
public ErrorWindow()
|
||||
|
|
|
@ -544,7 +544,7 @@ namespace PKHeX
|
|||
AddFontMemResourceEx(fontPtr, (uint)Resources.pgldings_normalregular.Length, IntPtr.Zero, ref dummy);
|
||||
Marshal.FreeCoTaskMem(fontPtr);
|
||||
}
|
||||
catch { Util.Error("Unable to add ingame font."); }
|
||||
catch (Exception ex) { Util.Error("Unable to add ingame font.", ex); }
|
||||
}
|
||||
|
||||
// Personal.dat
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace PKHeX
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Util.Error(ex.Message);
|
||||
Util.Error("An unexpected error has occurred.", ex);
|
||||
}
|
||||
}
|
||||
private void B_ExportPNG_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -193,7 +193,7 @@ namespace PKHeX
|
|||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
Util.Error("Drag & Drop Error:", x.ToString());
|
||||
Util.Error("Drag & Drop Error", x);
|
||||
}
|
||||
DragInfo.Reset();
|
||||
Cursor = DefaultCursor;
|
||||
|
|
|
@ -324,7 +324,7 @@ namespace PKHeX
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Util.Error(e.ToString());
|
||||
Util.Error("An unexpected error has occurred.", e);
|
||||
Console.Write(e);
|
||||
}
|
||||
TB_IsSet.Text = tbIsSet;
|
||||
|
@ -344,7 +344,7 @@ namespace PKHeX
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Util.Error(e.ToString());
|
||||
Util.Error("An unexpected error has occurred.", e);
|
||||
Console.Write(e);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace PKHeX
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Util.Error("Loading of data failed... is this really a Wonder Card?", e.ToString());
|
||||
Util.Error("Loading of data failed... is this really a Wonder Card?", e);
|
||||
RTB.Clear();
|
||||
}
|
||||
}
|
||||
|
@ -390,8 +390,8 @@ namespace PKHeX
|
|||
File.WriteAllBytes(newfile, card.Data);
|
||||
DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move);
|
||||
}
|
||||
catch (ArgumentException x)
|
||||
{ Util.Error("Drag & Drop Error:", x.ToString()); }
|
||||
catch (Exception x)
|
||||
{ Util.Error("Drag & Drop Error", x); }
|
||||
File.Delete(newfile);
|
||||
wc_slot = -1;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using PKHeX.Misc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
@ -9,7 +10,7 @@ namespace PKHeX
|
|||
{
|
||||
public partial class Util
|
||||
{
|
||||
// Form Translation
|
||||
#region Form Translation
|
||||
internal static void TranslateInterface(Control form, string lang)
|
||||
{
|
||||
// Check to see if a the translation file exists in the same folder as the executable
|
||||
|
@ -113,20 +114,40 @@ namespace PKHeX
|
|||
int y = parent.Location.Y + (parent.Height - child.Height) / 2;
|
||||
child.Location = new Point(Math.Max(x, 0), Math.Max(y, 0));
|
||||
}
|
||||
#endregion
|
||||
|
||||
// Message Displays
|
||||
#region Message Displays
|
||||
/// <summary>
|
||||
/// Displays a dialog showing the details of an error.
|
||||
/// </summary>
|
||||
/// <param name="friendlyMessage">User-friendly message about the error.</param>
|
||||
/// <param name="exception">Instance of the error's <see cref="Exception"/>.</param>
|
||||
/// <returns>The <see cref="DialogResult"/> associated with the dialog.</returns>
|
||||
internal static DialogResult Error(string friendlyMessage, Exception exception)
|
||||
{
|
||||
System.Media.SystemSounds.Exclamation.Play();
|
||||
return ErrorWindow.ShowErrorDialog(friendlyMessage, exception, true, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a dialog showing the details of an error.
|
||||
/// </summary>
|
||||
/// <param name="lines">User-friendly message about the error.</param>
|
||||
/// <returns>The <see cref="DialogResult"/> associated with the dialog.</returns>
|
||||
internal static DialogResult Error(params string[] lines)
|
||||
{
|
||||
System.Media.SystemSounds.Exclamation.Play();
|
||||
string msg = string.Join(Environment.NewLine + Environment.NewLine, lines);
|
||||
return MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
internal static DialogResult Alert(params string[] lines)
|
||||
{
|
||||
System.Media.SystemSounds.Asterisk.Play();
|
||||
string msg = string.Join(Environment.NewLine + Environment.NewLine, lines);
|
||||
return MessageBox.Show(msg, "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
|
||||
internal static DialogResult Prompt(MessageBoxButtons btn, params string[] lines)
|
||||
{
|
||||
System.Media.SystemSounds.Question.Play();
|
||||
|
@ -152,5 +173,6 @@ namespace PKHeX
|
|||
break;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue