Skip to content

Commit

Permalink
Standardize panic message syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Oct 7, 2024
1 parent c624480 commit 296841a
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 27 deletions.
14 changes: 7 additions & 7 deletions nautilus_core/indicators/src/indicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,31 @@ pub trait Indicator {
fn initialized(&self) -> bool;

fn handle_delta(&mut self, delta: &OrderBookDelta) {
panic!("`handle_delta` {} `{}`", IMPL_ERR, self.name());
panic!("`handle_delta` {IMPL_ERR} `{}`", self.name());
}

fn handle_deltas(&mut self, deltas: &OrderBookDeltas) {
panic!("`handle_deltas` {} `{}`", IMPL_ERR, self.name());
panic!("`handle_deltas` {IMPL_ERR} `{}`", self.name());
}

fn handle_depth(&mut self, depth: &OrderBookDepth10) {
panic!("`handle_depth` {} `{}`", IMPL_ERR, self.name());
panic!("`handle_depth` {IMPL_ERR} `{}`", self.name());
}

fn handle_book(&mut self, book: &OrderBook) {
panic!("`handle_book_mbo` {} `{}`", IMPL_ERR, self.name());
panic!("`handle_book_mbo` {IMPL_ERR} `{}`", self.name());
}

fn handle_quote(&mut self, quote: &QuoteTick) {
panic!("`handle_quote_tick` {} `{}`", IMPL_ERR, self.name());
panic!("`handle_quote_tick` {IMPL_ERR} `{}`", self.name());
}

fn handle_trade(&mut self, trade: &TradeTick) {
panic!("`handle_trade_tick` {} `{}`", IMPL_ERR, self.name());
panic!("`handle_trade_tick` {IMPL_ERR} `{}`", self.name());
}

fn handle_bar(&mut self, bar: &Bar) {
panic!("`handle_bar` {} `{}`", IMPL_ERR, self.name());
panic!("`handle_bar` {IMPL_ERR} `{}`", self.name());
}

fn reset(&mut self);
Expand Down
5 changes: 1 addition & 4 deletions nautilus_core/infrastructure/src/sql/models/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ impl<'r> FromRow<'r, PgRow> for OrderEventAnyModel {
let model = OrderUpdatedModel::from_row(row)?;
Ok(OrderEventAnyModel(OrderEventAny::Updated(model.0)))
} else {
panic!(
"Unknown order event kind: {} in Postgres transformation",
kind
)
panic!("Unknown order event kind: {kind} in Postgres transformation",)
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions nautilus_core/model/src/orders/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,8 @@ impl AsRef<StopMarketOrder> for OrderAny {
match self {
OrderAny::StopMarket(ref order) => order,
_ => panic!(
"Invalid `OrderAny` not `{}`, was {:?}",
"Invalid `OrderAny` not `{}`, was {self:?}",
stringify!(StopMarketOrder),
self
),
}
}
Expand Down
3 changes: 1 addition & 2 deletions nautilus_core/model/src/orders/limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,8 @@ impl From<OrderAny> for LimitOrder {
match order {
OrderAny::Limit(order) => order,
_ => panic!(
"Invalid `OrderAny` not `{}`, was {:?}",
"Invalid `OrderAny` not `{}`, was {order:?}",
stringify!(LimitOrder),
order
),
}
}
Expand Down
3 changes: 1 addition & 2 deletions nautilus_core/model/src/orders/limit_if_touched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,8 @@ impl From<OrderAny> for LimitIfTouchedOrder {
OrderAny::LimitIfTouched(order) => order,
_ => {
panic!(
"Invalid `OrderAny` not `{}`, was {:?}",
"Invalid `OrderAny` not `{}`, was {order:?}",
stringify!(LimitIfTouchedOrder),
order
)
}
}
Expand Down
3 changes: 1 addition & 2 deletions nautilus_core/model/src/orders/market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,8 @@ impl From<OrderAny> for MarketOrder {
OrderAny::Market(order) => order,
_ => {
panic!(
"Invalid `OrderAny` not `{}`, was {:?}",
"Invalid `OrderAny` not `{}`, was {order:?}",
stringify!(MarketOrder),
order
)
}
}
Expand Down
3 changes: 1 addition & 2 deletions nautilus_core/model/src/orders/market_if_touched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,8 @@ impl From<OrderAny> for MarketIfTouchedOrder {
OrderAny::MarketIfTouched(order) => order,
_ => {
panic!(
"Invalid `OrderAny` not `{}`, was {:?}",
"Invalid `OrderAny` not `{}`, was {order:?}",
stringify!(MarketIfTouchedOrder),
order
)
}
}
Expand Down
3 changes: 1 addition & 2 deletions nautilus_core/model/src/orders/stop_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,8 @@ impl From<OrderAny> for StopLimitOrder {
OrderAny::StopLimit(order) => order,
_ => {
panic!(
"Invalid `OrderAny` not `{}`, was {:?}",
"Invalid `OrderAny` not `{}`, was {order:?}",
stringify!(StopLimitOrder),
order
)
}
}
Expand Down
3 changes: 1 addition & 2 deletions nautilus_core/model/src/orders/trailing_stop_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,8 @@ impl From<OrderAny> for TrailingStopLimitOrder {
OrderAny::TrailingStopLimit(order) => order,
_ => {
panic!(
"Invalid `OrderAny` not `{}`, was {:?}",
"Invalid `OrderAny` not `{}`, was {order:?}",
stringify!(TrailingStopLimitOrder),
order
)
}
}
Expand Down
3 changes: 1 addition & 2 deletions nautilus_core/model/src/orders/trailing_stop_market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,8 @@ impl From<OrderAny> for TrailingStopMarketOrder {
OrderAny::TrailingStopMarket(order) => order,
_ => {
panic!(
"Invalid `OrderAny` not `{}`, was {:?}",
"Invalid `OrderAny` not `{}`, was {order:?}",
stringify!(TrailingStopMarketOrder),
order
)
}
}
Expand Down

0 comments on commit 296841a

Please sign in to comment.