Change verify macro to debug panic
Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
parent
2b979d3b88
commit
023ecd595b
8 changed files with 40 additions and 87 deletions
|
@ -11,6 +11,7 @@ test-support = ["serde_json", "tempdir", "git2"]
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1.0.38"
|
||||
backtrace = "0.3"
|
||||
futures = "0.3"
|
||||
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
||||
lazy_static = "1.4.0"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub mod test;
|
||||
|
||||
pub use backtrace::Backtrace;
|
||||
use futures::Future;
|
||||
use rand::{seq::SliceRandom, Rng};
|
||||
use std::{
|
||||
|
@ -10,6 +11,18 @@ use std::{
|
|||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! debug_panic {
|
||||
( $($fmt_arg:tt)* ) => {
|
||||
if cfg!(debug_assertions) {
|
||||
panic!( $($fmt_arg)* );
|
||||
} else {
|
||||
let backtrace = $crate::Backtrace::new();
|
||||
log::error!("{}\n{:?}", format_args!($($fmt_arg)*), backtrace);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub fn truncate(s: &str, max_chars: usize) -> &str {
|
||||
match s.char_indices().nth(max_chars) {
|
||||
None => s,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue