File tree 2 files changed +9
-4
lines changed
2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,8 @@ pub enum Error {
128
128
RuntimeTaskJoinError ( #[ from] tokio:: task:: JoinError ) ,
129
129
#[ error( "wal error: {0}" ) ]
130
130
LibsqlWal ( #[ from] libsql_wal:: error:: Error ) ,
131
+ #[ error( "database is not a primary" ) ]
132
+ NotAPrimary ,
131
133
}
132
134
133
135
impl AsRef < Self > for Error {
@@ -224,6 +226,7 @@ impl IntoResponse for &Error {
224
226
AttachInMigration => self . format_err ( StatusCode :: BAD_REQUEST ) ,
225
227
RuntimeTaskJoinError ( _) => self . format_err ( StatusCode :: INTERNAL_SERVER_ERROR ) ,
226
228
LibsqlWal ( _) => self . format_err ( StatusCode :: INTERNAL_SERVER_ERROR ) ,
229
+ NotAPrimary => self . format_err ( StatusCode :: BAD_REQUEST ) ,
227
230
}
228
231
}
229
232
}
Original file line number Diff line number Diff line change @@ -98,11 +98,13 @@ pub(super) async fn handle_dump(
98
98
let conn_maker = state
99
99
. namespaces
100
100
. with ( namespace, |ns| {
101
- assert ! ( ns. db. is_primary( ) ) ;
102
- ns. db . connection_maker ( )
101
+ if !ns. db . is_primary ( ) {
102
+ return Err ( Error :: NotAPrimary ) ;
103
+ }
104
+
105
+ Ok :: < _ , crate :: Error > ( ns. db . connection_maker ( ) )
103
106
} )
104
- . await
105
- . unwrap ( ) ;
107
+ . await ??;
106
108
107
109
let conn = conn_maker. create ( ) . await . unwrap ( ) ;
108
110
You can’t perform that action at this time.
0 commit comments