Skip to main content

cp_cli_platform_hackerrank/
error.rs

1#[derive(Debug, thiserror::Error)]
2pub enum Error {
3    #[error(
4        "HackerRank usernames must contain 1 to 128 ASCII letters, digits, dots, hyphens or underscores"
5    )]
6    InvalidUsername,
7    #[error(
8        "HackerRank slugs must contain 1 to 128 lowercase ASCII letters, digits, or internal hyphens"
9    )]
10    InvalidSlug,
11    #[error("HackerRank list offsets must be at most 1000000 and limits must be between 1 and 20")]
12    InvalidPage,
13    #[error("could not complete the HackerRank request; check your connection and try again")]
14    Transport(#[from] reqwest::Error),
15    #[error("HackerRank returned HTTP {0}")]
16    Status(reqwest::StatusCode),
17    #[error("HackerRank response exceeded {limit} bytes")]
18    ResponseTooLarge { limit: usize },
19    #[error("HackerRank returned JSON that cp-cli could not read: {0}")]
20    Decode(#[from] serde_json::Error),
21    #[error("HackerRank could not find that public problem")]
22    NotFound,
23    #[error("HackerRank returned incomplete or inconsistent problem data")]
24    InvalidResponse,
25}