Skip to content

Commit c6847a5

Browse files
committed
panic when the problem is locked
1 parent d683d19 commit c6847a5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ fn main() {
4141
}
4242

4343
let problem = problem::get_problem(id)
44-
.expect(&format!("problem #{} not found", id));
44+
.expect(&format!("Error: failed to get problem #{} \
45+
(The problem may be paid-only or may not be exist).",
46+
id));
4547
let code = problem.code_definition.iter()
4648
.filter(|&d| { d.value == "rust" })
4749
.next();

src/problem.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ pub fn get_problem(id: u32) -> Option<Problem> {
2121
let problems = get_problems().unwrap();
2222
for problem in problems.stat_status_pairs.iter() {
2323
if problem.stat.question_id == id {
24+
25+
if problem.paid_only {
26+
return None
27+
}
28+
2429
let client = reqwest::Client::new();
2530
let resp: RawProblem = client.post(GRAPHQL_URL)
2631
.json(&Query::question_query(problem.stat.question_title_slug.as_ref().unwrap()))

0 commit comments

Comments
 (0)