GameException.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Runtime.Serialization;
  3. namespace Model
  4. {
  5. [Serializable]
  6. public class GameException : Exception
  7. {
  8. public int ErrorCode { get; private set; }
  9. public string ErrorInfo { get; private set; }
  10. public GameException(int errorCode, string message): base(message)
  11. {
  12. this.ErrorCode = errorCode;
  13. }
  14. public GameException(int errorCode, string format, params object[] args)
  15. : base(string.Format(format, args))
  16. {
  17. this.ErrorCode = errorCode;
  18. }
  19. public GameException(int errorCode, string message, Exception innerException)
  20. : base(message, innerException)
  21. {
  22. this.ErrorCode = errorCode;
  23. }
  24. public GameException(int errorCode, string format, Exception innerException, params object[] args)
  25. : base(string.Format(format, args), innerException)
  26. {
  27. this.ErrorCode = errorCode;
  28. }
  29. protected GameException(SerializationInfo info, StreamingContext context)
  30. : base(info, context)
  31. {
  32. }
  33. public override string ToString()
  34. {
  35. return string.Format("error code: {0}, {1}", this.ErrorCode, base.ToString());
  36. }
  37. }
  38. }