Skip to content

Commit

Permalink
Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed May 30, 2016
1 parent ff971f7 commit c2a1c16
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
13 changes: 11 additions & 2 deletions ConfigGenerator/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ internal static void LogGenericInfoWithoutStacktrace(string message) {
MessageBox.Show(message, Resources.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
}

internal static void LogGenericError(string message, [CallerMemberName] string previousMethodName = null) {
internal static void LogGenericErrorWithoutStacktrace(string message) {
if (string.IsNullOrEmpty(message)) {
LogNullError(nameof(message));
return;
}

MessageBox.Show(previousMethodName + @"() " + message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}

internal static void LogGenericException(Exception exception, [CallerMemberName] string previousMethodName = null) {
Expand Down Expand Up @@ -87,5 +87,14 @@ internal static void LogNullError(string nullObjectName, [CallerMemberName] stri
break;
}
}

private static void LogGenericError(string message, [CallerMemberName] string previousMethodName = null) {
if (string.IsNullOrEmpty(message)) {
LogNullError(nameof(message));
return;
}

LogGenericErrorWithoutStacktrace(previousMethodName + @"() " + message);
}
}
}
10 changes: 5 additions & 5 deletions ConfigGenerator/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void MainTab_Selected(object sender, TabControlEventArgs args) {

if (configPage == ASFTab) {
MainTab.SelectedTab = ASFTab;
Logging.LogGenericError("You can't remove global config!");
Logging.LogGenericErrorWithoutStacktrace("You can't remove global config!");
return;
}

Expand All @@ -109,7 +109,7 @@ private void MainTab_Selected(object sender, TabControlEventArgs args) {

if (configPage == ASFTab) {
MainTab.SelectedTab = ASFTab;
Logging.LogGenericError("You can't rename global config!");
Logging.LogGenericErrorWithoutStacktrace("You can't rename global config!");
return;
}

Expand All @@ -121,7 +121,7 @@ private void MainTab_Selected(object sender, TabControlEventArgs args) {
}

if (string.IsNullOrEmpty(input)) {
Logging.LogGenericError("Your bot name is empty!");
Logging.LogGenericErrorWithoutStacktrace("Your bot name is empty!");
return;
}

Expand All @@ -147,15 +147,15 @@ private void MainTab_Selected(object sender, TabControlEventArgs args) {
}

if (string.IsNullOrEmpty(input)) {
Logging.LogGenericError("Your bot name is empty!");
Logging.LogGenericErrorWithoutStacktrace("Your bot name is empty!");
return;
}

// Get rid of any potential whitespaces in bot name
input = Regex.Replace(input, @"\s+", "");

if (ASFConfig.ASFConfigs.Select(config => Path.GetFileNameWithoutExtension(config.FilePath)).Any(fileNameWithoutExtension => (fileNameWithoutExtension == null) || fileNameWithoutExtension.Equals(input))) {
Logging.LogGenericError("Bot with such name exists already!");
Logging.LogGenericErrorWithoutStacktrace("Bot with such name exists already!");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion ConfigGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static void Init() {
return;
}

Logging.LogGenericError("Config directory could not be found!");
Logging.LogGenericErrorWithoutStacktrace("Config directory could not be found!");
Environment.Exit(1);
}

Expand Down

0 comments on commit c2a1c16

Please sign in to comment.