mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-11-07 09:45:36 +00:00
fix(api): reject empty ticker in resolve_symbol()
- Change resolve_symbol return type from String to Result<String, IdxError> - Add early validation for empty/whitespace-only ticker input - Return Err(IdxError::InvalidInput) for empty tickers - Add InvalidInput variant to IdxError enum - Update all 15 callers in cli/stocks.rs to handle Result with ? propagation - Update tests: empty/whitespace tickers now return error Fixes #7
This commit is contained in:
parent
bd4f3d49cc
commit
cd4d8d8323
3 changed files with 37 additions and 23 deletions
|
|
@ -30,6 +30,8 @@ pub enum IdxError {
|
|||
DatabaseError(String),
|
||||
#[error("PDF parse error: {0}")]
|
||||
PdfParseError(String),
|
||||
#[error("invalid input: {0}")]
|
||||
InvalidInput(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, PartialEq, Eq)]
|
||||
|
|
@ -47,6 +49,7 @@ pub enum ErrorCode {
|
|||
AuthError,
|
||||
DatabaseError,
|
||||
PdfParseError,
|
||||
InvalidInput,
|
||||
}
|
||||
|
||||
impl IdxError {
|
||||
|
|
@ -65,6 +68,7 @@ impl IdxError {
|
|||
Self::AuthError(_) => ErrorCode::AuthError,
|
||||
Self::DatabaseError(_) => ErrorCode::DatabaseError,
|
||||
Self::PdfParseError(_) => ErrorCode::PdfParseError,
|
||||
Self::InvalidInput(_) => ErrorCode::InvalidInput,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue