public void LogTest() { var testInnerException = new NoNullAllowedException(); var testException = new Exception("test exception", testInnerException); Assert.DoesNotThrow(() => _logLogic.Log(testException)); }
public void LogTestMessageContainsSensitiveData() { var testInnerException = new NoNullAllowedException(); var testException = new Exception("test exception Password", testInnerException); Assert.DoesNotThrow(() => _logLogic.Log(testException)); }
// public static TheDarkOwlLogger.TheDarkOwlLogger Bugger = new TheDarkOwlLogger.TheDarkOwlLogger(false, true, true, "WhiteTiger"); public static void errorreport(Exception e) { NoNullAllowedException nonullallowedext = new NoNullAllowedException(); System.Data.RowNotInTableException exrownotinTable = new RowNotInTableException(); System.ArgumentOutOfRangeException excarg = new ArgumentOutOfRangeException(); System.IO.FileNotFoundException filenotfound = new FileNotFoundException(); System.Xml.XmlException xmlexc = new XmlException(); if ((e.GetType() != nonullallowedext.GetType()) && (e.GetType() != exrownotinTable.GetType()) && (e.GetType() != excarg.GetType()) && (e.GetType() != filenotfound.GetType()) && (e.GetType() != xmlexc.GetType())) { logman.TraceException(e.Message, e); } }
public void AfterThrowing(NoNullAllowedException ex) { var a = 0; }
public ExceptionThrower() { NoNullAllowedException innerException = new NoNullAllowedException("Null ist nicht erlaubt!"); throw new FormatException("Fehlerhaftes Format!", innerException); }
private static string GetFieldName(NoNullAllowedException e) { return(GetFieldNameSimple(e.Message)); }
public static MyException TranslateException(Exception e, DataGridView dgv) { string s, msg = ""; if (e == null) { throw new ArgumentException(); } if (dgv == null) { return(new MyException(e.Message, e)); } DataTable dt = GetDataTableFromDataGridView(dgv); if (e is SqlException && e.Message.StartsWith(_sqlExceoptionStr1)) { //The UPDATE statement conflicted with the REFERENCE constraint \"fk_OPS_AC11_Acp21_AC\". The conflict occurred in database \"C:\\A1-DOCS\\C_NET\\KLONS1\\DB\\KLONS.MDF\", table \"dbo.OPS\", column 'AC11' SqlException esq = e as SqlException; //s = GetFieldName(esq, table); //s = table.Columns[s].Caption; msg = string.Format("Lauka vērtību nevar mainīt, " + "ja tā ir izmantota sistītā tabulā"); } else if (e is FbException && e.Message.StartsWith("violation of FOREIGN KEY constraint ")) { //violation of FOREIGN KEY constraint "FK_OPSD_CLID_PERSONS_CLID" on table "OPSD" Foreign key references are present for the record Problematic key value is ("CLID" = 'zapte') msg = string.Format("Darbību ar ierakstu nevar izpildīt, " + "ja tas ir izmantots sistītā tabulā"); } else if (e is DBConcurrencyException) { msg = "Izmaiņas neizdevās saglabāt,\n" + "jo ierakstu ir labojis cits lietotājs.\n" + "Mēģiniet pārlasīt tabulas datus."; } else if (e is NoNullAllowedException) { NoNullAllowedException enn = e as NoNullAllowedException; s = GetFieldName(enn); s = GetColumnDescr(dgv, s); msg = string.Format("Lauks [{0}] nevar būt tukšs", s); } else if (e is ConstraintException && e.Message.StartsWith("Column '") && e.Message.Contains("is constrained to be unique")) { //Column 'AC' is constrained to be unique. Value '1210' is already present. ConstraintException ec = e as ConstraintException; s = GetFieldName(ec); s = GetColumnDescr(dgv, s); msg = string.Format("Nekorekta lauka [{0}] vērtība" + " (šāda vērtība tabulā jau ir).", s); } else if (e is ConstraintException && e.Message.StartsWith("Failed to enable constraints. One or more rows contain")) { //Failed to enable constraints. One or more rows contain DetailedConstraintException de = new DetailedConstraintException(e.Message, GetDataTableFromDataGridView(dgv), e); msg = de.Message; } else if (e is InvalidConstraintException && e.Message.IndexOf("deleting") >= 0) { msg = "Ierakstu nevar dzēst, jo tam ir saistīti ieraksti citā tabulā."; } else if (e is InvalidConstraintException) { InvalidConstraintException eic = e as InvalidConstraintException; s = GetFieldName(eic, dt); s = GetColumnDescr(dgv, s); msg = string.Format("Nekorekta lauka [{0}] vērtība", s); } else if (e is ArgumentException && e.Message.Contains("The value violates the MaxLength limit")) { //ArgumentException: Cannot set column 'ClId'. The value violates the MaxLength limit of this column s = GetFieldName(e as ArgumentException); s = GetColumnDescr(dgv, s); msg = string.Format("Lauka [{0}] teksts ir par garu.", s); } else if (e is FormatException) { //Input string was not in a correct format. msg = string.Format("Ievadīta nekorekta lauka vērtība\n" + "(nekorekts ievadītā teksta formāts, ...)."); } if (msg == "") { msg = e.Message; } return(new MyException(msg, e)); }