Debian Codegraph @

src/error.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# as StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::{selfrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#, Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#};
3
4 use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::protocolrust-analyzer cargo sqlx-mysql 0.8.3 protocol/::responserust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/::ErrPacketrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/err/ErrPacket#;
5
6 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#;
7
8 pub(craterust-analyzer cargo sqlx-mysql 0.8.3 crate/) use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::errorrust-analyzer cargo sqlx-core 0.8.3 error/::*;
9
10 /// An error returned from the MySQL database.
11 pub struct MySqlDatabaseErrorrust-analyzer cargo sqlx-mysql 0.8.3 error/MySqlDatabaseError#(pub(superrust-analyzer cargo sqlx-mysql 0.8.3 crate/) ErrPacketrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/err/ErrPacket#);
12
13 impl MySqlDatabaseErrorrust-analyzer cargo sqlx-mysql 0.8.3 error/MySqlDatabaseError# {
14 /// The [SQLSTATE](https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html) code for this error.
15 pub fn coderust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError]code().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> {
16 self.0rust-analyzer cargo sqlx-mysql 0.8.3 error/MySqlDatabaseError#0..sql_staterust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/err/ErrPacket#sql_state..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
17 }
18
19 /// The [number](https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html)
20 /// for this error.
21 ///
22 /// MySQL tends to use SQLSTATE as a general error category, and the error number as a more
23 /// granular indication of the error.
24 pub fn numberrust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError]number().(&self) -> u16 {
25 self.0rust-analyzer cargo sqlx-mysql 0.8.3 error/MySqlDatabaseError#0..error_coderust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/err/ErrPacket#error_code.
26 }
27
28 /// The human-readable error message.
29 pub fn messagerust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError]message().(&self) -> &str {
30 &self.0rust-analyzer cargo sqlx-mysql 0.8.3 error/MySqlDatabaseError#0..error_messagerust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/err/ErrPacket#error_message.
31 }
32 }
33
34 impl Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for MySqlDatabaseErrorrust-analyzer cargo sqlx-mysql 0.8.3 error/MySqlDatabaseError# {
35 fn fmtrust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError][Debug]fmt().(&self, f: &mut Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
36 f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("MySqlDatabaseError")
37 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("code", &self.coderust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError]code().())
38 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("number", &self.numberrust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError]number().())
39 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("message", &self.messagerust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError]message().())
40 .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().()
41 }
42 }
43
44 impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for MySqlDatabaseErrorrust-analyzer cargo sqlx-mysql 0.8.3 error/MySqlDatabaseError# {
45 fn fmtrust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError][Display]fmt().(&self, f: &mut Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
46 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(code) = &self.coderust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError]code().() {
47 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{} ({}): {}", self.numberrust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError]number().(), code, self.messagerust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError]message().())
48 } else {
49 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}: {}", self.numberrust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError]number().(), self.messagerust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError]message().())
50 }
51 }
52 }
53
54 impl StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for MySqlDatabaseErrorrust-analyzer cargo sqlx-mysql 0.8.3 error/MySqlDatabaseError# {}
55
56 impl DatabaseErrorrust-analyzer cargo sqlx-core 0.8.3 error/DatabaseError# for MySqlDatabaseErrorrust-analyzer cargo sqlx-mysql 0.8.3 error/MySqlDatabaseError# {
57 #[inline]
58 fn messagerust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError][DatabaseError]message().(&self) -> &str {
59 self.messagerust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError]message().()
60 }
61
62 #[inline]
63 fn coderust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError][DatabaseError]code().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str>> {
64 self.coderust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError]code().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#)
65 }
66
67 #[doc(hidden)]
68 fn as_errorrust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError][DatabaseError]as_error().(&self) -> &(dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static) {
69 self
70 }
71
72 #[doc(hidden)]
73 fn as_error_mutrust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError][DatabaseError]as_error_mut().(&mut self) -> &mut (dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static) {
74 self
75 }
76
77 #[doc(hidden)]
78 fn into_errorrust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError][DatabaseError]into_error().(self: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<Selfrust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError][DatabaseError]>) -> Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static> {
79 self
80 }
81
82 fn kindrust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError][DatabaseError]kind().(&self) -> ErrorKindrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind# {
83 match self.numberrust-analyzer cargo sqlx-mysql 0.8.3 error/impl#[MySqlDatabaseError]number().() {
84 error_codesrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/::ER_DUP_KEYrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_DUP_KEY.
85 | error_codesrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/::ER_DUP_ENTRYrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_DUP_ENTRY.
86 | error_codesrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/::ER_DUP_UNIQUErust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_DUP_UNIQUE.
87 | error_codesrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/::ER_DUP_ENTRY_WITH_KEY_NAMErust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_DUP_ENTRY_WITH_KEY_NAME.
88 | error_codesrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/::ER_DUP_UNKNOWN_IN_INDEXrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_DUP_UNKNOWN_IN_INDEX. => ErrorKindrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#::UniqueViolationrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#UniqueViolation#,
89
90 error_codesrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/::ER_NO_REFERENCED_ROWrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_NO_REFERENCED_ROW.
91 | error_codesrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/::ER_NO_REFERENCED_ROW_2rust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_NO_REFERENCED_ROW_2.
92 | error_codesrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/::ER_ROW_IS_REFERENCEDrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_ROW_IS_REFERENCED.
93 | error_codesrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/::ER_ROW_IS_REFERENCED_2rust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_ROW_IS_REFERENCED_2.
94 | error_codesrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/::ER_FK_COLUMN_NOT_NULLrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_FK_COLUMN_NOT_NULL.
95 | error_codesrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/::ER_FK_CANNOT_DELETE_PARENTrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_FK_CANNOT_DELETE_PARENT. => ErrorKindrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#::ForeignKeyViolationrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#ForeignKeyViolation#,
96
97 error_codesrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/::ER_BAD_NULL_ERRORrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_BAD_NULL_ERROR. | error_codesrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/::ER_NO_DEFAULT_FOR_FIELDrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_NO_DEFAULT_FOR_FIELD. => {
98 ErrorKindrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#::NotNullViolationrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#NotNullViolation#
99 }
100
101 error_codesrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/::ER_CHECK_CONSTRAINT_VIOLATEDrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_CHECK_CONSTRAINT_VIOLATED. => ErrorKindrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#::CheckViolationrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#CheckViolation#,
102
103 // https://mariadb.com/kb/en/e4025/
104 error_codesrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/::mariadbrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/mariadb/::ER_CONSTRAINT_FAILEDrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/mariadb/ER_CONSTRAINT_FAILED.
105 // MySQL uses this code for a completely different error,
106 // but we can differentiate by SQLSTATE:
107 // <https://dev.mysql.com/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_innodb_autoextend_size_out_of_range
108 if self.0rust-analyzer cargo sqlx-mysql 0.8.3 error/MySqlDatabaseError#0..sql_staterust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/err/ErrPacket#sql_state..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("23000") =>
109 {
110 ErrorKindrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#::CheckViolationrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#CheckViolation#
111 }
112
113 _ => ErrorKindrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#::Otherrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#Other#,
114 }
115 }
116 }
117
118 /// The MySQL server uses SQLSTATEs as a generic error category,
119 /// and returns a `error_code` instead within the error packet.
120 ///
121 /// For reference: <https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html>.
122 pub(craterust-analyzer cargo sqlx-mysql 0.8.3 crate/) mod error_codesrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ {
123 /// Caused when a DDL operation creates duplicated keys.
124 pub const ER_DUP_KEYrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_DUP_KEY.: u16 = 1022;
125 /// Caused when a DML operation tries create a duplicated entry for a key,
126 /// be it a unique or primary one.
127 pub const ER_DUP_ENTRYrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_DUP_ENTRY.: u16 = 1062;
128 /// Similar to `ER_DUP_ENTRY`, but only present in NDB clusters.
129 ///
130 /// See: <https://github.com/mysql/mysql-server/blob/fbdaa4def30d269bc4de5b85de61de34b11c0afc/mysql-test/suite/stress/include/ddl7.inc#L68>.
131 pub const ER_DUP_UNIQUErust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_DUP_UNIQUE.: u16 = 1169;
132 /// Similar to `ER_DUP_ENTRY`, but with a formatted string message.
133 ///
134 /// See: <https://bugs.mysql.com/bug.php?id=46976>.
135 pub const ER_DUP_ENTRY_WITH_KEY_NAMErust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_DUP_ENTRY_WITH_KEY_NAME.: u16 = 1586;
136 /// Caused when a DDL operation to add a unique index fails,
137 /// because duplicate items were created by concurrent DML operations.
138 /// When this happens, the key is unknown, so the server can't use `ER_DUP_KEY`.
139 ///
140 /// For example: an `INSERT` operation creates duplicate `name` fields when `ALTER`ing a table and making `name` unique.
141 pub const ER_DUP_UNKNOWN_IN_INDEXrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_DUP_UNKNOWN_IN_INDEX.: u16 = 1859;
142
143 /// Caused when inserting an entry with a column with a value that does not reference a foreign row.
144 pub const ER_NO_REFERENCED_ROWrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_NO_REFERENCED_ROW.: u16 = 1216;
145 /// Caused when deleting a row that is referenced in other tables.
146 pub const ER_ROW_IS_REFERENCEDrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_ROW_IS_REFERENCED.: u16 = 1217;
147 /// Caused when deleting a row that is referenced in other tables.
148 /// This differs from `ER_ROW_IS_REFERENCED` in that the error message contains the affected constraint.
149 pub const ER_ROW_IS_REFERENCED_2rust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_ROW_IS_REFERENCED_2.: u16 = 1451;
150 /// Caused when inserting an entry with a column with a value that does not reference a foreign row.
151 /// This differs from `ER_NO_REFERENCED_ROW` in that the error message contains the affected constraint.
152 pub const ER_NO_REFERENCED_ROW_2rust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_NO_REFERENCED_ROW_2.: u16 = 1452;
153 /// Caused when creating a FK with `ON DELETE SET NULL` or `ON UPDATE SET NULL` to a column that is `NOT NULL`, or vice-versa.
154 pub const ER_FK_COLUMN_NOT_NULLrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_FK_COLUMN_NOT_NULL.: u16 = 1830;
155 /// Removed in 5.7.3.
156 pub const ER_FK_CANNOT_DELETE_PARENTrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_FK_CANNOT_DELETE_PARENT.: u16 = 1834;
157
158 /// Caused when inserting a NULL value to a column marked as NOT NULL.
159 pub const ER_BAD_NULL_ERRORrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_BAD_NULL_ERROR.: u16 = 1048;
160 /// Caused when inserting a DEFAULT value to a column marked as NOT NULL, which also doesn't have a default value set.
161 pub const ER_NO_DEFAULT_FOR_FIELDrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_NO_DEFAULT_FOR_FIELD.: u16 = 1364;
162
163 /// Caused when a check constraint is violated.
164 ///
165 /// Only available after 8.0.16.
166 pub const ER_CHECK_CONSTRAINT_VIOLATEDrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/ER_CHECK_CONSTRAINT_VIOLATED.: u16 = 3819;
167
168 pub(craterust-analyzer cargo sqlx-mysql 0.8.3 crate/) mod mariadbrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/mariadb/ {
169 /// Error code emitted by MariaDB for constraint errors: <https://mariadb.com/kb/en/e4025/>
170 ///
171 /// MySQL emits this code for a completely different error:
172 /// <https://dev.mysql.com/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_innodb_autoextend_size_out_of_range>
173 ///
174 /// You also check that SQLSTATE is `23000`.
175 pub const ER_CONSTRAINT_FAILEDrust-analyzer cargo sqlx-mysql 0.8.3 error/error_codes/mariadb/ER_CONSTRAINT_FAILED.: u16 = 4025;
176 }
177 }