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.

110 lines
3.3 KiB

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