PageRenderTime 56ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/user_interface/src/UserInterface/Error.cs

https://github.com/shranjan/pinac
C# | 54 lines | 28 code | 5 blank | 21 comment | 11 complexity | 471659517156eed7c7349ba9e7a225fe MD5 | raw file
  1. //////////////////////////////////////////////////////////////////////////////////
  2. // Error.cs - Error handling class //
  3. // ver 1.0 //
  4. // //
  5. // Language: C# //
  6. // Platform: Windows 7 //
  7. // Application: SPINACH //
  8. // Author: Abhay Ketkar (asketkar@syr.edu) //
  9. // (315) 439 7224 //
  10. //////////////////////////////////////////////////////////////////////////////////
  11. /*
  12. * Maintenance History:
  13. * ====================
  14. * version 1.0 : 4 Nov 09
  15. * - the initial version of the Error module
  16. */
  17. using System;
  18. using System.Collections.Generic;
  19. namespace UserInterface
  20. {
  21. /// <summary>
  22. ///
  23. /// </summary>
  24. public delegate void ErrorNotification(string Msg);
  25. public class ErrorModule
  26. {
  27. public event ErrorNotification ConnError;
  28. public event ErrorNotification ProgConfError;
  29. public event ErrorNotification ProgWinError;
  30. private Dictionary<int, string> ErrorDict = new Dictionary<int, string>();
  31. //----< Create the Dictionary of Errors >----
  32. public ErrorModule()
  33. {
  34. ErrorDict.Add(101, "Syntax Error: ");
  35. ErrorDict.Add(102, "Exception: ");
  36. }
  37. //----< Sends Error Message to appropriate window >----
  38. public void ErrorMsg(int Code, string Msg)
  39. {
  40. string ErrMsg = ErrorDict[Code] + Msg;
  41. if (Code < 50 && ConnError != null)
  42. ConnError(ErrMsg);
  43. else if (Code < 100 && ProgConfError != null)
  44. ProgConfError(ErrMsg);
  45. else if (Code < 150 && ProgWinError != null)
  46. ProgWinError(ErrMsg);
  47. }
  48. }
  49. }