Skip to content

Commit 2a0245f

Browse files
committed
Standardize errors section in doc comments
1 parent 552517d commit 2a0245f

File tree

6 files changed

+33
-22
lines changed

6 files changed

+33
-22
lines changed

RELEASES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Released on TBD (UTC).
66
- Added `PerContractFeeModel`, thanks @stefansimik
77
- Added additional timestamp properties for `NautilusKernel`
88
- Allow bar aggregators to persist after `request_aggregated_bars` (#2144), thanks @faysou
9+
- Handle directory and live streams to catalog (#2153), thanks @limx0
910

1011
### Internal Improvements
1112
- Improved market order handling when no size available in book (now explicitly rejects)

nautilus_core/model/src/data/bar.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ impl BarSpecification {
137137
Self::new_checked(step, aggregation, price_type).expect(FAILED)
138138
}
139139

140+
/// Creates a new [`BarSpecification`] instance with correctness checking.
141+
///
142+
/// # Errors
143+
///
144+
/// This function returns an error:
145+
/// - If `step` is not positive (> 0).
146+
///
147+
/// # Notes
148+
///
149+
/// PyO3 requires a `Result` type for proper error handling and stacktrace printing in Python.
140150
pub fn new_checked(
141151
step: usize,
142152
aggregation: BarAggregation,
@@ -584,10 +594,10 @@ impl Bar {
584594
///
585595
/// # Errors
586596
///
587-
/// This function returns an error if:
588-
/// - `high` is not >= `low`.
589-
/// - `high` is not >= `close`.
590-
/// - `low` is not <= `close.
597+
/// This function returns an error:
598+
/// - If `high` is not >= `low`.
599+
/// - If `high` is not >= `close`.
600+
/// - If `low` is not <= `close.
591601
///
592602
/// # Notes
593603
///

nautilus_core/model/src/data/delta.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ impl OrderBookDelta {
9292
///
9393
/// # Errors
9494
///
95-
/// This function returns an error if:
96-
/// - `action` is [`BookAction::Add`] or [`BookAction::Update`] and `size` is not positive (> 0).
95+
/// This function returns an error:
96+
/// - If `action` is [`BookAction::Add`] or [`BookAction::Update`] and `size` is not positive (> 0).
9797
///
9898
/// # Notes
9999
///

nautilus_core/model/src/data/quote.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ impl QuoteTick {
9191
///
9292
/// # Errors
9393
///
94-
/// This function returns an error if:
95-
/// - `bid_price.precision` does not equal `ask_price.precision`.
96-
/// - `bid_size.precision` does not equal `ask_size.precision`.
94+
/// This function returns an error:
95+
/// - If `bid_price.precision` does not equal `ask_price.precision`.
96+
/// - If `bid_size.precision` does not equal `ask_size.precision`.
9797
///
9898
/// # Notes
9999
///

nautilus_core/model/src/data/trade.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ impl TradeTick {
9191
///
9292
/// # Errors
9393
///
94-
/// This function returns an error if:
95-
/// - `size` is not positive (> 0).
94+
/// This function returns an error:
95+
/// - If `size` is not positive (> 0).
9696
///
9797
/// # Notes
9898
///

nautilus_core/model/src/identifiers/trade_id.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ impl TradeId {
5555
///
5656
/// # Errors
5757
///
58-
/// This function returns an error if:
59-
/// - `value` is an invalid string (e.g., is empty or contains non-ASCII characters).
60-
/// - `value` length exceeds 36 characters.
58+
/// This function returns an error:
59+
/// - If `value` is an invalid string (e.g., is empty or contains non-ASCII characters).
60+
/// - If `value` length exceeds 36 characters.
6161
///
6262
/// # Notes
6363
///
@@ -72,9 +72,9 @@ impl TradeId {
7272
///
7373
/// # Errors
7474
///
75-
/// This function returns an error if:
76-
/// - `value` is an invalid string (e.g., is empty or contains non-ASCII characters).
77-
/// - `value` length exceeds 36 characters.
75+
/// This function returns an error:
76+
/// - If `value` is an invalid string (e.g., is empty or contains non-ASCII characters).
77+
/// - If `value` length exceeds 36 characters.
7878
pub fn new<T: AsRef<str>>(value: T) -> Self {
7979
Self::new_checked(value).expect(FAILED)
8080
}
@@ -85,11 +85,11 @@ impl TradeId {
8585
///
8686
/// # Panics
8787
///
88-
/// This function panics if:
89-
/// - The byte slice is empty or consists only of a single null byte.
90-
/// - The byte slice exceeds 36 bytes and does not end with a null byte.
91-
/// - The byte slice is exactly 37 bytes but the last byte is not null.
92-
/// - The byte slice contains non-ASCII characters.
88+
/// This function panics:
89+
/// - If `value` is empty or consists only of a single null byte.
90+
/// - If `value` exceeds 36 bytes and does not end with a null byte.
91+
/// - If `value` is exactly 37 bytes but the last byte is not null.
92+
/// - If `value` contains non-ASCII characters.
9393
pub fn from_bytes(value: &[u8]) -> anyhow::Result<Self> {
9494
check_slice_not_empty(value, "value")?;
9595

0 commit comments

Comments
 (0)