• Home
  • Raw
  • Download

Lines Matching +full:write +full:- +full:error

4 use std::error;
14 pub enum Error { enum
15 /// An error from an underlying SQLite call.
16 SqliteFailure(ffi::Error, Option<String>),
18 /// Error reported when attempting to open a connection when SQLite was
19 /// configured to allow single-threaded use only.
22 /// Error when the value of a particular column is requested, but it cannot
24 FromSqlConversionFailure(usize, Type, Box<dyn error::Error + Send + Sync + 'static>),
26 /// Error when SQLite gives us an integral value outside the range of the
32 /// Error converting a string to UTF-8.
35 /// Error converting a string to a C-compatible string because it contained
39 /// Error when using SQL named parameters and passing a parameter name not
43 /// Error converting a file path to a string.
46 /// Error returned when an [`execute`](crate::Connection::execute) call
50 /// Error when a query that was expected to return at least one row (e.g.,
54 /// Error when the value of a particular column is requested, but the index
58 /// Error when the value of a named column is requested, but no column
62 /// Error when the value of a particular column is requested, but the type
67 /// Error when a query that was expected to insert one row did not insert
71 /// Error returned by
77 /// Error returned by [`vtab::Values::get`](crate::vtab::Values::get) when
83 /// An error case available for implementors of custom user functions (e.g.,
88 UserFunctionError(Box<dyn error::Error + Send + Sync + 'static>),
90 /// Error available for the implementors of the
92 ToSqlConversionFailure(Box<dyn error::Error + Send + Sync + 'static>),
94 /// Error when the SQL is not a `SELECT`, is not read-only.
97 /// An error case available for implementors of custom modules (e.g.,
104 /// An unwinding panic occurs in an UDF (user-defined function).
109 /// An error returned when
117 /// Error when the SQL contains multiple statements.
119 /// Error when the number of bound parameters does not match the number of
131 /// Error referencing a specific token in the input SQL
135 /// error code
136 error: ffi::Error,
137 /// error message
146 impl PartialEq for Error { implementation
147 fn eq(&self, other: &Error) -> bool { in eq()
149 (Error::SqliteFailure(e1, s1), Error::SqliteFailure(e2, s2)) => e1 == e2 && s1 == s2, in eq()
150 (Error::SqliteSingleThreadedMode, Error::SqliteSingleThreadedMode) => true, in eq()
151 (Error::IntegralValueOutOfRange(i1, n1), Error::IntegralValueOutOfRange(i2, n2)) => { in eq()
154 (Error::Utf8Error(e1), Error::Utf8Error(e2)) => e1 == e2, in eq()
155 (Error::NulError(e1), Error::NulError(e2)) => e1 == e2, in eq()
156 (Error::InvalidParameterName(n1), Error::InvalidParameterName(n2)) => n1 == n2, in eq()
157 (Error::InvalidPath(p1), Error::InvalidPath(p2)) => p1 == p2, in eq()
158 (Error::ExecuteReturnedResults, Error::ExecuteReturnedResults) => true, in eq()
159 (Error::QueryReturnedNoRows, Error::QueryReturnedNoRows) => true, in eq()
160 (Error::InvalidColumnIndex(i1), Error::InvalidColumnIndex(i2)) => i1 == i2, in eq()
161 (Error::InvalidColumnName(n1), Error::InvalidColumnName(n2)) => n1 == n2, in eq()
162 (Error::InvalidColumnType(i1, n1, t1), Error::InvalidColumnType(i2, n2, t2)) => { in eq()
165 (Error::StatementChangedRows(n1), Error::StatementChangedRows(n2)) => n1 == n2, in eq()
168 Error::InvalidFunctionParameterType(i1, t1), in eq()
169 Error::InvalidFunctionParameterType(i2, t2), in eq()
173 Error::InvalidFilterParameterType(i1, t1), in eq()
174 Error::InvalidFilterParameterType(i2, t2), in eq()
176 (Error::InvalidQuery, Error::InvalidQuery) => true, in eq()
178 (Error::ModuleError(s1), Error::ModuleError(s2)) => s1 == s2, in eq()
180 (Error::UnwindingPanic, Error::UnwindingPanic) => true, in eq()
182 (Error::GetAuxWrongType, Error::GetAuxWrongType) => true, in eq()
183 (Error::InvalidParameterCount(i1, n1), Error::InvalidParameterCount(i2, n2)) => { in eq()
187 (Error::BlobSizeError, Error::BlobSizeError) => true, in eq()
190 Error::SqlInputError { in eq()
191 error: e1, in eq()
196 Error::SqlInputError { in eq()
197 error: e2, in eq()
208 impl From<str::Utf8Error> for Error { implementation
210 fn from(err: str::Utf8Error) -> Error { in from() argument
211 Error::Utf8Error(err) in from()
215 impl From<std::ffi::NulError> for Error { implementation
217 fn from(err: std::ffi::NulError) -> Error { in from() argument
218 Error::NulError(err) in from()
225 /// to allow use of `get_raw(…).as_…()?` in callbacks that take `Error`.
226 impl From<FromSqlError> for Error { implementation
228 fn from(err: FromSqlError) -> Error { in from() argument
229 // The error type requires index and type fields, but they aren't known in this in from()
232 FromSqlError::OutOfRange(val) => Error::IntegralValueOutOfRange(UNKNOWN_COLUMN, val), in from()
234 Error::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Blob, Box::new(err)) in from()
237 Error::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Null, source) in from()
239 _ => Error::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Null, Box::new(err)), in from()
244 impl fmt::Display for Error { implementation
245 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { in fmt()
247 Error::SqliteFailure(ref err, None) => err.fmt(f), in fmt()
248 Error::SqliteFailure(_, Some(ref s)) => write!(f, "{s}"), in fmt()
249 Error::SqliteSingleThreadedMode => write!( in fmt()
251 "SQLite was compiled or configured for single-threaded use only" in fmt()
253 Error::FromSqlConversionFailure(i, ref t, ref err) => { in fmt()
255 write!( in fmt()
257 "Conversion error from type {} at index: {}, {}", in fmt()
264 Error::IntegralValueOutOfRange(col, val) => { in fmt()
266 write!(f, "Integer {val} out of range at index {col}") in fmt()
268 write!(f, "Integer {val} out of range") in fmt()
271 Error::Utf8Error(ref err) => err.fmt(f), in fmt()
272 Error::NulError(ref err) => err.fmt(f), in fmt()
273 Error::InvalidParameterName(ref name) => write!(f, "Invalid parameter name: {name}"), in fmt()
274 Error::InvalidPath(ref p) => write!(f, "Invalid path: {}", p.to_string_lossy()), in fmt()
275 Error::ExecuteReturnedResults => { in fmt()
276 write!(f, "Execute returned results - did you mean to call query?") in fmt()
278 Error::QueryReturnedNoRows => write!(f, "Query returned no rows"), in fmt()
279 Error::InvalidColumnIndex(i) => write!(f, "Invalid column index: {i}"), in fmt()
280 Error::InvalidColumnName(ref name) => write!(f, "Invalid column name: {name}"), in fmt()
281 Error::InvalidColumnType(i, ref name, ref t) => write!( in fmt()
286 Error::InvalidParameterCount(i1, n1) => write!( in fmt()
291 Error::StatementChangedRows(i) => write!(f, "Query changed {i} rows"), in fmt()
294 Error::InvalidFunctionParameterType(i, ref t) => { in fmt()
295 write!(f, "Invalid function parameter type {t} at index {i}") in fmt()
298 Error::InvalidFilterParameterType(i, ref t) => { in fmt()
299 write!(f, "Invalid filter parameter type {t} at index {i}") in fmt()
302 Error::UserFunctionError(ref err) => err.fmt(f), in fmt()
303 Error::ToSqlConversionFailure(ref err) => err.fmt(f), in fmt()
304 Error::InvalidQuery => write!(f, "Query is not read-only"), in fmt()
306 Error::ModuleError(ref desc) => write!(f, "{desc}"), in fmt()
308 Error::UnwindingPanic => write!(f, "unwinding panic"), in fmt()
310 Error::GetAuxWrongType => write!(f, "get_aux called with wrong type"), in fmt()
311 Error::MultipleStatement => write!(f, "Multiple statements provided"), in fmt()
313 Error::BlobSizeError => "Blob size is insufficient".fmt(f), in fmt()
315 Error::SqlInputError { in fmt()
320 } => write!(f, "{msg} in {sql} at offset {offset}"), in fmt()
325 impl error::Error for Error { implementation
326 fn source(&self) -> Option<&(dyn error::Error + 'static)> { in source()
328 Error::SqliteFailure(ref err, _) => Some(err), in source()
329 Error::Utf8Error(ref err) => Some(err), in source()
330 Error::NulError(ref err) => Some(err), in source()
332 Error::IntegralValueOutOfRange(..) in source()
333 | Error::SqliteSingleThreadedMode in source()
334 | Error::InvalidParameterName(_) in source()
335 | Error::ExecuteReturnedResults in source()
336 | Error::QueryReturnedNoRows in source()
337 | Error::InvalidColumnIndex(_) in source()
338 | Error::InvalidColumnName(_) in source()
339 | Error::InvalidColumnType(..) in source()
340 | Error::InvalidPath(_) in source()
341 | Error::InvalidParameterCount(..) in source()
342 | Error::StatementChangedRows(_) in source()
343 | Error::InvalidQuery in source()
344 | Error::MultipleStatement => None, in source()
347 Error::InvalidFunctionParameterType(..) => None, in source()
349 Error::InvalidFilterParameterType(..) => None, in source()
352 Error::UserFunctionError(ref err) => Some(&**err), in source()
354 Error::FromSqlConversionFailure(_, _, ref err) in source()
355 | Error::ToSqlConversionFailure(ref err) => Some(&**err), in source()
358 Error::ModuleError(_) => None, in source()
361 Error::UnwindingPanic => None, in source()
364 Error::GetAuxWrongType => None, in source()
367 Error::BlobSizeError => None, in source()
369 Error::SqlInputError { ref error, .. } => Some(error), in source()
374 impl Error { impl
375 /// Returns the underlying SQLite error if this is [`Error::SqliteFailure`].
377 pub fn sqlite_error(&self) -> Option<&ffi::Error> { in sqlite_error() argument
379 Self::SqliteFailure(error, _) => Some(error), in sqlite_error()
384 /// Returns the underlying SQLite error code if this is
385 /// [`Error::SqliteFailure`].
387 pub fn sqlite_error_code(&self) -> Option<ffi::ErrorCode> { in sqlite_error_code()
388 self.sqlite_error().map(|error| error.code) in sqlite_error_code()
392 // These are public but not re-exported by lib.rs, so only visible within crate.
395 pub fn error_from_sqlite_code(code: c_int, message: Option<String>) -> Error { in error_from_sqlite_code() argument
397 Error::SqliteFailure(ffi::Error::new(code), message) in error_from_sqlite_code()
401 pub unsafe fn error_from_handle(db: *mut ffi::sqlite3, code: c_int) -> Error { in error_from_handle() argument
412 pub unsafe fn error_with_offset(db: *mut ffi::sqlite3, code: c_int, _sql: &str) -> Error { in error_with_offset() argument
418 pub unsafe fn error_with_offset(db: *mut ffi::sqlite3, code: c_int, sql: &str) -> Error { in error_with_offset() argument
422 let error = ffi::Error::new(code); in error_with_offset() localVariable
424 if ffi::ErrorCode::Unknown == error.code { in error_with_offset()
427 return Error::SqlInputError { in error_with_offset()
428 error, in error_with_offset()
435 Error::SqliteFailure(error, Some(msg)) in error_with_offset()
439 pub fn check(code: c_int) -> Result<()> { in check()