You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(jd-client): propagate initialization errors instead of
panicking
Replaces several `expect()` and `unwrap()` calls in
`JobDeclaratorClient::start`
with proper error propagation using `Result`.
- Updated `start()` signature to return
`JDCError<JobDeclarationClient>`.
- Introduced `InitializationError(String)` variant to `JDCErrorKind` to
preserve context from formerly panicking calls.
- Updated `main.rs` and integration tests to handle the new `Result`
type
- Fix clippy and fmt checks
error!(error = ?e,"Failed to initialize channel manager");
127
131
self.cancellation_token.cancel();
128
132
self.shutdown_notify.notify_waiters();
129
133
self.is_alive.store(false,Ordering::Relaxed);
130
-
return;
134
+
135
+
returnErr(JDCError::shutdown(e.kind));
131
136
}
132
137
};
133
138
@@ -207,11 +212,11 @@ impl JobDeclaratorClient {
207
212
{
208
213
Ok(template_receiver) => template_receiver,
209
214
Err(e) => {
210
-
error!(error = ?e,"Failed to initialize SV2 template receiver");
211
215
self.cancellation_token.cancel();
212
216
self.shutdown_notify.notify_waiters();
213
217
self.is_alive.store(false,Ordering::Relaxed);
214
-
return;
218
+
219
+
returnErr(JDCError::shutdown(e.kind));
215
220
}
216
221
};
217
222
@@ -235,13 +240,11 @@ impl JobDeclaratorClient {
235
240
){
236
241
Some(unix_socket_path) => unix_socket_path,
237
242
None => {
238
-
error!(
239
-
"Could not determine Bitcoin data directory. Please set data_dir in config."
240
-
);
241
243
self.cancellation_token.cancel();
242
244
self.shutdown_notify.notify_waiters();
243
245
self.is_alive.store(false,Ordering::Relaxed);
244
-
return;
246
+
247
+
returnErr(JDCError::shutdown(JDCErrorKind::InitializationError("Could not determine Bitcoin data directory. Please set data_dir in config.".to_string())));
0 commit comments