You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.8 KiB

4 years ago
  1. // Copyright ?2004, 2010, Oracle and/or its affiliates. All rights reserved.
  2. //
  3. // MySQL Connector/NET is licensed under the terms of the GPLv2
  4. // <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
  5. // MySQL Connectors. There are special exceptions to the terms and
  6. // conditions of the GPLv2 as it is applied to this software, see the
  7. // FLOSS License Exception
  8. // <http://www.mysql.com/about/legal/licensing/foss-exception.html>.
  9. //
  10. // This program is free software; you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published
  12. // by the Free Software Foundation; version 2 of the License.
  13. //
  14. // This program is distributed in the hope that it will be useful, but
  15. // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  16. // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  17. // for more details.
  18. //
  19. // You should have received a copy of the GNU General Public License along
  20. // with this program; if not, write to the Free Software Foundation, Inc.,
  21. // 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  22. #if MYSQL_6_9
  23. using System;
  24. using System.Data.Common;
  25. using System.Runtime.Serialization;
  26. namespace Externals.MySql.Data.MySqlClient
  27. {
  28. /// <summary>
  29. /// The exception that is thrown when MySQL returns an error. This class cannot be inherited.
  30. /// </summary>
  31. [Serializable]
  32. internal sealed class MySqlException : DbException
  33. {
  34. private int errorCode;
  35. private bool isFatal;
  36. internal MySqlException()
  37. {
  38. }
  39. internal MySqlException(string msg)
  40. : base(msg)
  41. {
  42. }
  43. internal MySqlException(string msg, Exception ex)
  44. : base(msg, ex)
  45. {
  46. }
  47. internal MySqlException(string msg, bool isFatal, Exception inner)
  48. : base(msg, inner)
  49. {
  50. this.isFatal = isFatal;
  51. }
  52. internal MySqlException(string msg, int errno, Exception inner)
  53. : this(msg, inner)
  54. {
  55. errorCode = errno;
  56. Data.Add("Server Error Code", errno);
  57. }
  58. internal MySqlException(string msg, int errno)
  59. : this(msg, errno, null)
  60. {
  61. }
  62. private MySqlException(SerializationInfo info, StreamingContext context)
  63. : base(info, context)
  64. {
  65. }
  66. /// <summary>
  67. /// Gets a number that identifies the type of error.
  68. /// </summary>
  69. public int Number
  70. {
  71. get { return errorCode; }
  72. }
  73. /// <summary>
  74. /// True if this exception was fatal and cause the closing of the connection, false otherwise.
  75. /// </summary>
  76. internal bool IsFatal
  77. {
  78. get { return isFatal; }
  79. }
  80. internal bool IsQueryAborted
  81. {
  82. get
  83. {
  84. return (errorCode == (int)MySqlErrorCode.QueryInterrupted ||
  85. errorCode == (int)MySqlErrorCode.FileSortAborted);
  86. }
  87. }
  88. }
  89. }
  90. #endif