/// <summary> /// Throw exception. /// </summary> /// <param name="line">Line.</param> /// <param name="message">Error message.</param> private Exception Throw(int line, string message) { if (db != null) { db.Dispose(); } return(new MochaException($"{line}{message}")); }
private void ConnectButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(pathTB.Text)) { pathTB.BorderColor = Color.Red; return; } MochaDatabase db = null; try { db = new MochaDatabase($@" AutoConnect=True; Path={pathTB.Text}; Password={passwordTB.Text}; Logs={logToggle.Checked}"); var connectionPanel = new cncpanel(db); CNCList.AddItem(new sbutton() { Text = fs.GetFileNameFromPath(pathTB.Text), Tag = connectionPanel }); Close(); } catch (MochaException excep) { if (db != null) { db.Dispose(); } if (excep.Message == "MochaDB database password does not match the password specified!" || excep.Message == "The MochaDB database is password protected!") { passwordTB.BorderColor = Color.Red; } else { errorbox.Show("[MochaException]\n" + excep.Message); } } catch (Exception excep) { if (db != null) { db.Dispose(); } errorbox.Show("[Exception]\n" + excep.Message + excep); } }