couchbase-shell icon indicating copy to clipboard operation
couchbase-shell copied to clipboard

Remove expect and unwrap from codebase

Open chvck opened this issue 2 years ago • 2 comments

If we're going to fail something we should do it gracefully and at least attempt to give the user some information about why we've failed. We shouldn't just panic.

chvck avatar Jul 27 '23 08:07 chvck

expect and unwrap in main.rs are probably ok, these happen at startup. unwrap when taking a lock also ok, this can only happen if the lock has been poisoned, i.e. a panic occurred in another thread which has holding the lock - this a) shouldn't be happening and b) is probably unrecoverable.

chvck avatar Aug 07 '23 10:08 chvck

@chvck What about the numerous engine_state.ctrlc.as_ref().unwrap().clone(); ? Also there are a few places where we do serde_json::to_string(json).unwrap() and we know we are passing in valid json since it's a server response. And I'd say that Runtime::new().unwrap(); seems okay.

Westwooo avatar Apr 11 '24 14:04 Westwooo