| 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 atoirust-analyzer cargo atoi 2.0.0 crate/::atoirust-analyzer cargo atoi 2.0.0 atoi().; |
| 5 | use smallvecrust-analyzer cargo smallvec 1.15.2 crate/::allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc 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#; |
| 6 | use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::bytesrust-analyzer cargo bytes 1.12.1 crate/::Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#; |
| 7 | pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::errorrust-analyzer cargo sqlx-core 0.8.3 error/::*; |
| 8 | |
| 9 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::messagerust-analyzer cargo sqlx-postgres 0.8.3 message/::{BackendMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessage#, BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#, Noticerust-analyzer cargo sqlx-postgres 0.8.3 message/response/Notice#, PgSeverityrust-analyzer cargo sqlx-postgres 0.8.3 message/response/PgSeverity#}; |
| 10 | |
| 11 | /// An error returned from the PostgreSQL database. |
| 12 | pub struct PgDatabaseErrorrust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#(pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) Noticerust-analyzer cargo sqlx-postgres 0.8.3 message/response/Notice#); |
| 13 | |
| 14 | // Error message fields are documented: |
| 15 | // https://www.postgresql.org/docs/current/protocol-error-fields.html |
| 16 | |
| 17 | impl PgDatabaseErrorrust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError# { |
| 18 | #[inline] |
| 19 | pub fn severityrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]severity().(&self) -> PgSeverityrust-analyzer cargo sqlx-postgres 0.8.3 message/response/PgSeverity# { |
| 20 | self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0..severityrust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]severity().() |
| 21 | } |
| 22 | |
| 23 | /// The [SQLSTATE](https://www.postgresql.org/docs/current/errcodes-appendix.html) code for |
| 24 | /// this error. |
| 25 | #[inline] |
| 26 | pub fn coderust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]code().(&self) -> &str { |
| 27 | self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0..coderust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]code().() |
| 28 | } |
| 29 | |
| 30 | /// The primary human-readable error message. This should be accurate but |
| 31 | /// terse (typically one line). |
| 32 | #[inline] |
| 33 | pub fn messagerust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]message().(&self) -> &str { |
| 34 | self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0..messagerust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]message().() |
| 35 | } |
| 36 | |
| 37 | /// An optional secondary error message carrying more detail about the problem. |
| 38 | /// Might run to multiple lines. |
| 39 | #[inline] |
| 40 | pub fn detailrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]detail().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> { |
| 41 | self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0..getrust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]get().(b'D') |
| 42 | } |
| 43 | |
| 44 | /// An optional suggestion what to do about the problem. This is intended to differ from |
| 45 | /// `detail` in that it offers advice (potentially inappropriate) rather than hard facts. |
| 46 | /// Might run to multiple lines. |
| 47 | #[inline] |
| 48 | pub fn hintrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]hint().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> { |
| 49 | self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0..getrust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]get().(b'H') |
| 50 | } |
| 51 | |
| 52 | /// Indicates an error cursor position as an index into the original query string; or, |
| 53 | /// a position into an internally generated query. |
| 54 | #[inline] |
| 55 | pub fn positionrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]position().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<PgErrorPositionrust-analyzer cargo sqlx-postgres 0.8.3 error/PgErrorPosition#<'_>> { |
| 56 | self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0. |
| 57 | .get_rawrust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]get_raw().(b'P') |
| 58 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(atoirust-analyzer cargo atoi 2.0.0 atoi().) |
| 59 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(PgErrorPositionrust-analyzer cargo sqlx-postgres 0.8.3 error/PgErrorPosition#::Originalrust-analyzer cargo sqlx-postgres 0.8.3 error/PgErrorPosition#Original#) |
| 60 | .or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]or_else().(|| { |
| 61 | let position = self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0..get_rawrust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]get_raw().(b'p').and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(atoirust-analyzer cargo atoi 2.0.0 atoi().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 62 | let query = self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0..getrust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]get().(b'q')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 63 | |
| 64 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PgErrorPositionrust-analyzer cargo sqlx-postgres 0.8.3 error/PgErrorPosition#::Internalrust-analyzer cargo sqlx-postgres 0.8.3 error/PgErrorPosition#Internal# { positionrust-analyzer cargo sqlx-postgres 0.8.3 error/PgErrorPosition#Internal#position., queryrust-analyzer cargo sqlx-postgres 0.8.3 error/PgErrorPosition#Internal#query. }) |
| 65 | }) |
| 66 | } |
| 67 | |
| 68 | /// An indication of the context in which the error occurred. Presently this includes a call |
| 69 | /// stack traceback of active procedural language functions and internally-generated queries. |
| 70 | /// The trace is one entry per line, most recent first. |
| 71 | pub fn r#whererust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]`r#where`().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> { |
| 72 | self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0..getrust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]get().(b'W') |
| 73 | } |
| 74 | |
| 75 | /// If this error is with a specific database object, the |
| 76 | /// name of the schema containing that object, if any. |
| 77 | pub fn schemarust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]schema().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> { |
| 78 | self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0..getrust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]get().(b's') |
| 79 | } |
| 80 | |
| 81 | /// If this error is with a specific table, the name of the table. |
| 82 | pub fn tablerust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]table().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> { |
| 83 | self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0..getrust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]get().(b't') |
| 84 | } |
| 85 | |
| 86 | /// If the error is with a specific table column, the name of the column. |
| 87 | pub fn columnrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]column().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> { |
| 88 | self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0..getrust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]get().(b'c') |
| 89 | } |
| 90 | |
| 91 | /// If the error is with a specific data type, the name of the data type. |
| 92 | pub fn data_typerust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]data_type().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> { |
| 93 | self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0..getrust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]get().(b'd') |
| 94 | } |
| 95 | |
| 96 | /// If the error is with a specific constraint, the name of the constraint. |
| 97 | /// For this purpose, indexes are constraints, even if they weren't created |
| 98 | /// with constraint syntax. |
| 99 | pub fn constraintrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]constraint().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> { |
| 100 | self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0..getrust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]get().(b'n') |
| 101 | } |
| 102 | |
| 103 | /// The file name of the source-code location where this error was reported. |
| 104 | pub fn filerust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]file().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> { |
| 105 | self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0..getrust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]get().(b'F') |
| 106 | } |
| 107 | |
| 108 | /// The line number of the source-code location where this error was reported. |
| 109 | pub fn linerust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]line().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize> { |
| 110 | self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0..get_rawrust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]get_raw().(b'L').and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(atoirust-analyzer cargo atoi 2.0.0 atoi().) |
| 111 | } |
| 112 | |
| 113 | /// The name of the source-code routine reporting this error. |
| 114 | pub fn routinerust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]routine().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> { |
| 115 | self.0rust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError#0..getrust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice]get().(b'R') |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 120 | pub enum PgErrorPositionrust-analyzer cargo sqlx-postgres 0.8.3 error/PgErrorPosition#<'a> { |
| 121 | /// A position (in characters) into the original query. |
| 122 | Originalrust-analyzer cargo sqlx-postgres 0.8.3 error/PgErrorPosition#Original#(usize), |
| 123 | |
| 124 | /// A position into the internally-generated query. |
| 125 | Internalrust-analyzer cargo sqlx-postgres 0.8.3 error/PgErrorPosition#Internal# { |
| 126 | /// The position in characters. |
| 127 | positionrust-analyzer cargo sqlx-postgres 0.8.3 error/PgErrorPosition#Internal#position.: usize, |
| 128 | |
| 129 | /// The text of a failed internally-generated command. This could be, for example, |
| 130 | /// the SQL query issued by a PL/pgSQL function. |
| 131 | queryrust-analyzer cargo sqlx-postgres 0.8.3 error/PgErrorPosition#Internal#query.: &'a str, |
| 132 | }, |
| 133 | } |
| 134 | |
| 135 | impl Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for PgDatabaseErrorrust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError# { |
| 136 | fn fmtrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError][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# { |
| 137 | f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("PgDatabaseError") |
| 138 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("severity", &self.severityrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]severity().()) |
| 139 | .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-postgres 0.8.3 error/impl#[PgDatabaseError]code().()) |
| 140 | .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-postgres 0.8.3 error/impl#[PgDatabaseError]message().()) |
| 141 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("detail", &self.detailrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]detail().()) |
| 142 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("hint", &self.hintrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]hint().()) |
| 143 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("position", &self.positionrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]position().()) |
| 144 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("where", &self.r#whererust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]`r#where`().()) |
| 145 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("schema", &self.schemarust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]schema().()) |
| 146 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("table", &self.tablerust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]table().()) |
| 147 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("column", &self.columnrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]column().()) |
| 148 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("data_type", &self.data_typerust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]data_type().()) |
| 149 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("constraint", &self.constraintrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]constraint().()) |
| 150 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("file", &self.filerust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]file().()) |
| 151 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("line", &self.linerust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]line().()) |
| 152 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("routine", &self.routinerust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]routine().()) |
| 153 | .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().() |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for PgDatabaseErrorrust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError# { |
| 158 | fn fmtrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError][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# { |
| 159 | f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(self.messagerust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]message().()) |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | impl StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for PgDatabaseErrorrust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError# {} |
| 164 | |
| 165 | impl DatabaseErrorrust-analyzer cargo sqlx-core 0.8.3 error/DatabaseError# for PgDatabaseErrorrust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError# { |
| 166 | fn messagerust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError][DatabaseError]message().(&self) -> &str { |
| 167 | self.messagerust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]message().() |
| 168 | } |
| 169 | |
| 170 | fn coderust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError][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>> { |
| 171 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(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#(self.coderust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]code().())) |
| 172 | } |
| 173 | |
| 174 | #[doc(hidden)] |
| 175 | fn as_errorrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError][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) { |
| 176 | self |
| 177 | } |
| 178 | |
| 179 | #[doc(hidden)] |
| 180 | fn as_error_mutrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError][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) { |
| 181 | self |
| 182 | } |
| 183 | |
| 184 | #[doc(hidden)] |
| 185 | fn into_errorrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError][DatabaseError]into_error().(self: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError][DatabaseError]>) -> BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError# { |
| 186 | self |
| 187 | } |
| 188 | |
| 189 | fn is_transient_in_connect_phaserust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError][DatabaseError]is_transient_in_connect_phase().(&self) -> bool { |
| 190 | // https://www.postgresql.org/docs/current/errcodes-appendix.html |
| 191 | [ |
| 192 | // too_many_connections |
| 193 | // This may be returned if we just un-gracefully closed a connection, |
| 194 | // give the database a chance to notice it and clean it up. |
| 195 | "53300", |
| 196 | // cannot_connect_now |
| 197 | // Returned if the database is still starting up. |
| 198 | "57P03", |
| 199 | ] |
| 200 | .containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&self.coderust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]code().()) |
| 201 | } |
| 202 | |
| 203 | fn constraintrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError][DatabaseError]constraint().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> { |
| 204 | self.constraintrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]constraint().() |
| 205 | } |
| 206 | |
| 207 | fn tablerust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError][DatabaseError]table().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> { |
| 208 | self.tablerust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]table().() |
| 209 | } |
| 210 | |
| 211 | fn kindrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError][DatabaseError]kind().(&self) -> ErrorKindrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind# { |
| 212 | match self.coderust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError]code().() { |
| 213 | error_codesrust-analyzer cargo sqlx-postgres 0.8.3 error/error_codes/::UNIQUE_VIOLATIONrust-analyzer cargo sqlx-postgres 0.8.3 error/error_codes/UNIQUE_VIOLATION. => ErrorKindrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#::UniqueViolationrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#UniqueViolation#, |
| 214 | error_codesrust-analyzer cargo sqlx-postgres 0.8.3 error/error_codes/::FOREIGN_KEY_VIOLATIONrust-analyzer cargo sqlx-postgres 0.8.3 error/error_codes/FOREIGN_KEY_VIOLATION. => ErrorKindrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#::ForeignKeyViolationrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#ForeignKeyViolation#, |
| 215 | error_codesrust-analyzer cargo sqlx-postgres 0.8.3 error/error_codes/::NOT_NULL_VIOLATIONrust-analyzer cargo sqlx-postgres 0.8.3 error/error_codes/NOT_NULL_VIOLATION. => ErrorKindrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#::NotNullViolationrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#NotNullViolation#, |
| 216 | error_codesrust-analyzer cargo sqlx-postgres 0.8.3 error/error_codes/::CHECK_VIOLATIONrust-analyzer cargo sqlx-postgres 0.8.3 error/error_codes/CHECK_VIOLATION. => ErrorKindrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#::CheckViolationrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#CheckViolation#, |
| 217 | _ => ErrorKindrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#::Otherrust-analyzer cargo sqlx-core 0.8.3 error/ErrorKind#Other#, |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | // ErrorResponse is the same structure as NoticeResponse but a different format code. |
| 223 | impl BackendMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessage# for PgDatabaseErrorrust-analyzer cargo sqlx-postgres 0.8.3 error/PgDatabaseError# { |
| 224 | const FORMATrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError][BackendMessage]FORMAT.: BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat# = BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::ErrorResponserust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#ErrorResponse#; |
| 225 | |
| 226 | #[inline(always)] |
| 227 | fn decode_bodyrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError][BackendMessage]decode_body().(buf: Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError][BackendMessage], Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 228 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo sqlx-postgres 0.8.3 error/impl#[PgDatabaseError][BackendMessage](Noticerust-analyzer cargo sqlx-postgres 0.8.3 message/response/Notice#::decode_bodyrust-analyzer cargo sqlx-postgres 0.8.3 message/response/impl#[Notice][BackendMessage]decode_body().(buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)) |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | /// For reference: <https://www.postgresql.org/docs/current/errcodes-appendix.html> |
| 233 | pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) mod error_codesrust-analyzer cargo sqlx-postgres 0.8.3 error/error_codes/ { |
| 234 | /// Caused when a unique or primary key is violated. |
| 235 | pub const UNIQUE_VIOLATIONrust-analyzer cargo sqlx-postgres 0.8.3 error/error_codes/UNIQUE_VIOLATION.: &str = "23505"; |
| 236 | /// Caused when a foreign key is violated. |
| 237 | pub const FOREIGN_KEY_VIOLATIONrust-analyzer cargo sqlx-postgres 0.8.3 error/error_codes/FOREIGN_KEY_VIOLATION.: &str = "23503"; |
| 238 | /// Caused when a column marked as NOT NULL received a null value. |
| 239 | pub const NOT_NULL_VIOLATIONrust-analyzer cargo sqlx-postgres 0.8.3 error/error_codes/NOT_NULL_VIOLATION.: &str = "23502"; |
| 240 | /// Caused when a check constraint is violated. |
| 241 | pub const CHECK_VIOLATIONrust-analyzer cargo sqlx-postgres 0.8.3 error/error_codes/CHECK_VIOLATION.: &str = "23514"; |
| 242 | } |