Skip to content

Commit 53674d0

Browse files
committed
Add ErrorDetails proto for errors
1 parent 94217e2 commit 53674d0

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

libsql-storage/proto/storage.proto

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ message DestroyRequest {
6767

6868
message DestroyResponse {}
6969

70+
enum ErrorCode {
71+
INTERNAL_ERROR = 0;
72+
WRITE_CONFLICT = 1;
73+
}
74+
75+
message ErrorDetails {
76+
ErrorCode code = 1;
77+
string message = 2;
78+
}
79+
7080
service Storage {
7181
rpc InsertFrames(InsertFramesRequest) returns (InsertFramesResponse) {}
7282
rpc FindFrame(FindFrameRequest) returns (FindFrameResponse) {}

libsql-storage/src/generated/storage.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,40 @@ pub struct DestroyRequest {
100100
#[allow(clippy::derive_partial_eq_without_eq)]
101101
#[derive(Clone, PartialEq, ::prost::Message)]
102102
pub struct DestroyResponse {}
103+
#[allow(clippy::derive_partial_eq_without_eq)]
104+
#[derive(Clone, PartialEq, ::prost::Message)]
105+
pub struct ErrorDetails {
106+
#[prost(enumeration = "ErrorCode", tag = "1")]
107+
pub code: i32,
108+
#[prost(string, tag = "2")]
109+
pub message: ::prost::alloc::string::String,
110+
}
111+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
112+
#[repr(i32)]
113+
pub enum ErrorCode {
114+
InternalError = 0,
115+
WriteConflict = 1,
116+
}
117+
impl ErrorCode {
118+
/// String value of the enum field names used in the ProtoBuf definition.
119+
///
120+
/// The values are not transformed in any way and thus are considered stable
121+
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
122+
pub fn as_str_name(&self) -> &'static str {
123+
match self {
124+
ErrorCode::InternalError => "INTERNAL_ERROR",
125+
ErrorCode::WriteConflict => "WRITE_CONFLICT",
126+
}
127+
}
128+
/// Creates an enum from field names used in the ProtoBuf definition.
129+
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
130+
match value {
131+
"INTERNAL_ERROR" => Some(Self::InternalError),
132+
"WRITE_CONFLICT" => Some(Self::WriteConflict),
133+
_ => None,
134+
}
135+
}
136+
}
103137
/// Generated client implementations.
104138
pub mod storage_client {
105139
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]

0 commit comments

Comments
 (0)