public ErrorException(Errors.Category category, int code) { this.err.category = category; this.err.code = code; Errors inst = Errors.GetInstance(); if (category == Errors.Category.Warning) { this.err.msg = inst.GetWarningError(code).msg; } else if (category == Errors.Category.Serious) { this.err.msg = inst.GetSeriousError(code).msg; } else if (category == Errors.Category.Fatal) { this.err.msg = inst.GetFatalError(code).msg; } }
/** * Return the singleton instance of Errors. * * @return the instance of this class * * @refcode N/A * @errtest * N/A * @errmsg * N/A * @author Mark Mathis * @creation April 14, 2011 * @modlog * @codestandard Mark Mathis * @teststandard Andrew Buelow */ public static Errors GetInstance() { if (Errors.instance == null) { Errors.instance = new Errors(); } return Errors.instance; }
/** * Add an error to this line. * * @param level the severity of the error * @param code code of the error to store * @refcode N/A * @errtest N/A * @errmsg N/A * @author Jacob * @creation April 15, 2011 * @modlog * - April 16, 2011 - Jacob - Changed to use an Error struct. * - April 17, 2011 - Jacob - Look up an error code instead of a message. * - April 17, 2011 - Andrew - Added logging to this procedure. * @teststandard Andrew Buelow * @codestandard Mark Mathis */ public void AddError(Errors.Category level, int code) { Logger.Log("Found " + level.ToString() + " error number " + code + ". Adding to error list.", "IntermediateLine"); Parser.TotalErrors++; Errors inst = Errors.GetInstance(); // Get the correct error based on category and add to the list of errors for this line. if (level == Errors.Category.Warning) { this.errors.Add(inst.GetWarningError(code)); } else if (level == Errors.Category.Serious) { this.errors.Add(inst.GetSeriousError(code)); } else if (level == Errors.Category.Fatal) { this.errors.Add(inst.GetFatalError(code)); this.Fatal = true; } }