re-export crates used by error macros

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-09-12 00:59:08 +00:00 committed by strawberry
parent f7ce4db0b0
commit a5de27442a
2 changed files with 18 additions and 15 deletions

View file

@ -44,34 +44,34 @@ macro_rules! err {
(Request(Forbidden($level:ident!($($args:tt)+)))) => {{ (Request(Forbidden($level:ident!($($args:tt)+)))) => {{
let mut buf = String::new(); let mut buf = String::new();
$crate::error::Error::Request( $crate::error::Error::Request(
::ruma::api::client::error::ErrorKind::forbidden(), $crate::ruma::api::client::error::ErrorKind::forbidden(),
$crate::err_log!(buf, $level, $($args)+), $crate::err_log!(buf, $level, $($args)+),
::http::StatusCode::BAD_REQUEST $crate::http::StatusCode::BAD_REQUEST
) )
}}; }};
(Request(Forbidden($($args:tt)+))) => { (Request(Forbidden($($args:tt)+))) => {
$crate::error::Error::Request( $crate::error::Error::Request(
::ruma::api::client::error::ErrorKind::forbidden(), $crate::ruma::api::client::error::ErrorKind::forbidden(),
$crate::format_maybe!($($args)+), $crate::format_maybe!($($args)+),
::http::StatusCode::BAD_REQUEST $crate::http::StatusCode::BAD_REQUEST
) )
}; };
(Request($variant:ident($level:ident!($($args:tt)+)))) => {{ (Request($variant:ident($level:ident!($($args:tt)+)))) => {{
let mut buf = String::new(); let mut buf = String::new();
$crate::error::Error::Request( $crate::error::Error::Request(
::ruma::api::client::error::ErrorKind::$variant, $crate::ruma::api::client::error::ErrorKind::$variant,
$crate::err_log!(buf, $level, $($args)+), $crate::err_log!(buf, $level, $($args)+),
::http::StatusCode::BAD_REQUEST $crate::http::StatusCode::BAD_REQUEST
) )
}}; }};
(Request($variant:ident($($args:tt)+))) => { (Request($variant:ident($($args:tt)+))) => {
$crate::error::Error::Request( $crate::error::Error::Request(
::ruma::api::client::error::ErrorKind::$variant, $crate::ruma::api::client::error::ErrorKind::$variant,
$crate::format_maybe!($($args)+), $crate::format_maybe!($($args)+),
::http::StatusCode::BAD_REQUEST $crate::http::StatusCode::BAD_REQUEST
) )
}; };
@ -113,7 +113,7 @@ macro_rules! err_log {
($out:ident, $level:ident, $($fields:tt)+) => {{ ($out:ident, $level:ident, $($fields:tt)+) => {{
use std::{fmt, fmt::Write}; use std::{fmt, fmt::Write};
use ::tracing::{ use $crate::tracing::{
callsite, callsite2, level_enabled, metadata, valueset, Callsite, Event, __macro_support, callsite, callsite2, level_enabled, metadata, valueset, Callsite, Event, __macro_support,
__tracing_log, __tracing_log,
field::{Field, ValueSet, Visit}, field::{Field, ValueSet, Visit},
@ -169,25 +169,25 @@ macro_rules! err_log {
macro_rules! err_lev { macro_rules! err_lev {
(debug_warn) => { (debug_warn) => {
if $crate::debug::logging() { if $crate::debug::logging() {
::tracing::Level::WARN $crate::tracing::Level::WARN
} else { } else {
::tracing::Level::DEBUG $crate::tracing::Level::DEBUG
} }
}; };
(debug_error) => { (debug_error) => {
if $crate::debug::logging() { if $crate::debug::logging() {
::tracing::Level::ERROR $crate::tracing::Level::ERROR
} else { } else {
::tracing::Level::DEBUG $crate::tracing::Level::DEBUG
} }
}; };
(warn) => { (warn) => {
::tracing::Level::WARN $crate::tracing::Level::WARN
}; };
(error) => { (error) => {
::tracing::Level::ERROR $crate::tracing::Level::ERROR
}; };
} }

View file

@ -11,7 +11,10 @@ pub mod result;
pub mod server; pub mod server;
pub mod utils; pub mod utils;
pub use ::http;
pub use ::ruma;
pub use ::toml; pub use ::toml;
pub use ::tracing;
pub use config::Config; pub use config::Config;
pub use error::Error; pub use error::Error;
pub use info::{rustc_flags_capture, version, version::version}; pub use info::{rustc_flags_capture, version, version::version};