PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/Spinach/UserInterface/Error.cs

https://github.com/shranjan/SPINACH
C# | 79 lines | 45 code | 10 blank | 24 comment | 11 complexity | e93a8d9ae8cce98d55601a692cd53da9 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. using Spinach;
  20. namespace Spinach
  21. {
  22. /// <summary>
  23. ///
  24. /// </summary>
  25. public delegate void ErrorNotification(string Msg);
  26. public class ErrorModule
  27. {
  28. public event ErrorNotification ConnError;
  29. public event ErrorNotification ProgConfError;
  30. public event ErrorNotification ProgWinError;
  31. private executor Ex;
  32. private PlotReceiver plot;
  33. private Dictionary<int, string> ErrorDict = new Dictionary<int, string>();
  34. //----< Create the Dictionary of Errors >----
  35. public ErrorModule()
  36. {
  37. // FrontEnd Error Messages
  38. ErrorDict.Add(101, "Syntax Error: ");
  39. ErrorDict.Add(102, "Exception: ");
  40. // CoreTeam Error Messages
  41. ErrorDict.Add(112, "Semantic Error: ");
  42. // PlotTeam Error Messages
  43. ErrorDict.Add(121, "Plotting Error: ");
  44. ErrorDict.Add(122, "Plotting Error: ");
  45. ErrorDict.Add(123, "Plotting Error: ");
  46. }
  47. //----< Sends Error Message to appropriate window >----
  48. public void ErrorMsg(int Code, string Msg)
  49. {
  50. string ErrMsg = ErrorDict[Code] + Msg;
  51. if (Code < 50 && ConnError != null)
  52. ConnError(ErrMsg);
  53. else if (Code < 100 && ProgConfError != null)
  54. ProgConfError(ErrMsg);
  55. else if (Code < 150 && ProgWinError != null)
  56. ProgWinError(ErrMsg);
  57. }
  58. public void SetExecutorObject(executor E)
  59. {
  60. Ex = E;
  61. Ex.errEvent +=new executor.err(ErrorMsg);
  62. }
  63. public void SetPlotObject(PlotReceiver p)
  64. {
  65. plot = p;
  66. plot.error +=new PlotReceiver.PlotError(ErrorMsg);
  67. }
  68. }
  69. }