Optimized unneccesary try-catch block

This commit is contained in:
2023-03-29 09:25:12 +02:00
parent 6536ea3fb9
commit 226612f49c

View File

@@ -20,12 +20,10 @@ namespace Password_Manager
public static void Init() public static void Init()
{ {
try if (File.Exists(CONFIGPATH))
{ {
StreamReader sr = new StreamReader(CONFIGPATH); StreamReader sr = new StreamReader(CONFIGPATH);
string? path = null, recipient = null; string? path = null, recipient = null;
if (sr != null)
{
while (!sr.EndOfStream) while (!sr.EndOfStream)
{ {
string[]? fields = sr.ReadLine().Split(DELIMETER); string[]? fields = sr.ReadLine().Split(DELIMETER);
@@ -56,17 +54,8 @@ namespace Password_Manager
} }
} }
else else
{
throw new FileNotFoundException();
}
}
catch (FileNotFoundException)
{ {
CreateDefaultConfig(); CreateDefaultConfig();
}
catch (IOException e)
{
MessageBox.Show(e.ToString(), "IO Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }