Archived
1
0
Fork 0
forked from Anri/cal8tor
This repository has been archived on 2023-04-23. You can view files and clone it, but cannot push or open issues or pull requests.
cal8tor/src/utils.rs
2022-08-23 17:53:57 +02:00

23 lines
605 B
Rust

/// Panic if an error happened
pub fn check_errors(html: &String, loc: &str) {
match html {
t if t.contains(&err_code(429)) => panic!(
"URL: {} • HTTP 429: Slow down - Rate limited (too many access attempts detected)",
loc
),
_ => (),
}
}
/// Create String error code
fn err_code(code: i32) -> String {
format!("HTTP Code : {}", code)
}
/// Return the string if exists, otherwise return empty string
pub fn display_option(o: &Option<String>) -> String {
match o {
Some(s) => s.to_string(),
None => String::new(),
}
}