Optimized unneccesary try-catch block
This commit is contained in:
@@ -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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user