1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// Unified Query Algebra
//
// Copyright (c) 2023-2026 Cognica, Inc.
//
use crate::SQLError;
/// An atomic batch failure with its original SQL error and, when known, zero-based member.
/// Transaction begin, commit and rollback failures are not attributed to a member.
#[derive(Debug, thiserror::Error)]
#[error("{error}")]
pub struct SQLBatchError {
#[source]
pub error: SQLError,
pub statement_index: Option<usize>,
}
impl SQLBatchError {
pub const fn statement(error: SQLError, statement_index: usize) -> Self {
Self {
error,
statement_index: Some(statement_index),
}
}
pub const fn transaction(error: SQLError) -> Self {
Self {
error,
statement_index: None,
}
}
pub fn into_error(self) -> SQLError {
self.error
}
}