Skip to content

Commit c2a1c16

Browse files
committed
Misc
1 parent ff971f7 commit c2a1c16

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

ConfigGenerator/Logging.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ internal static void LogGenericInfoWithoutStacktrace(string message) {
3939
MessageBox.Show(message, Resources.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
4040
}
4141

42-
internal static void LogGenericError(string message, [CallerMemberName] string previousMethodName = null) {
42+
internal static void LogGenericErrorWithoutStacktrace(string message) {
4343
if (string.IsNullOrEmpty(message)) {
4444
LogNullError(nameof(message));
4545
return;
4646
}
4747

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

5151
internal static void LogGenericException(Exception exception, [CallerMemberName] string previousMethodName = null) {
@@ -87,5 +87,14 @@ internal static void LogNullError(string nullObjectName, [CallerMemberName] stri
8787
break;
8888
}
8989
}
90+
91+
private static void LogGenericError(string message, [CallerMemberName] string previousMethodName = null) {
92+
if (string.IsNullOrEmpty(message)) {
93+
LogNullError(nameof(message));
94+
return;
95+
}
96+
97+
LogGenericErrorWithoutStacktrace(previousMethodName + @"() " + message);
98+
}
9099
}
91100
}

ConfigGenerator/MainForm.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private void MainTab_Selected(object sender, TabControlEventArgs args) {
8787

8888
if (configPage == ASFTab) {
8989
MainTab.SelectedTab = ASFTab;
90-
Logging.LogGenericError("You can't remove global config!");
90+
Logging.LogGenericErrorWithoutStacktrace("You can't remove global config!");
9191
return;
9292
}
9393

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

110110
if (configPage == ASFTab) {
111111
MainTab.SelectedTab = ASFTab;
112-
Logging.LogGenericError("You can't rename global config!");
112+
Logging.LogGenericErrorWithoutStacktrace("You can't rename global config!");
113113
return;
114114
}
115115

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

123123
if (string.IsNullOrEmpty(input)) {
124-
Logging.LogGenericError("Your bot name is empty!");
124+
Logging.LogGenericErrorWithoutStacktrace("Your bot name is empty!");
125125
return;
126126
}
127127

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

149149
if (string.IsNullOrEmpty(input)) {
150-
Logging.LogGenericError("Your bot name is empty!");
150+
Logging.LogGenericErrorWithoutStacktrace("Your bot name is empty!");
151151
return;
152152
}
153153

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

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

ConfigGenerator/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private static void Init() {
7979
return;
8080
}
8181

82-
Logging.LogGenericError("Config directory could not be found!");
82+
Logging.LogGenericErrorWithoutStacktrace("Config directory could not be found!");
8383
Environment.Exit(1);
8484
}
8585

0 commit comments

Comments
 (0)