ottojo / uulm_mensa_bot

Cafeteria order lib/cli/bot for uulm
2 stars 0 forks source link

panic when no meals are available #4

Open ottojo opened 1 year ago

ottojo commented 1 year ago
jonas@sol3:uulm_mensa_cli$ RUST_LOG="my_mensa_lib=trace" cargo run -- 2 menu  
    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
     Running `/home/jonas/Projects/uulm_mensa_bot/target/debug/uulm_mensa_cli 2 menu`
 TRACE my_mensa_lib > Calling API url: https://stwulm.my-mensa.de/getdata.php?mensa_id=2&json=1&hyp=1&now=1692825929683&mode=togo&lang=de
 TRACE my_mensa_lib > Response: Response { url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("stwulm.my-mensa.de")), port: None, path: "/getdata.php", query: Some("mensa_id=2&json=1&hyp=1&now=1692825929683&mode=togo&lang=de"), fragment: None }, status: 200, headers: {"server": "nginx", "date": "Wed, 23 Aug 2023 21:25:30 GMT", "content-type": "application/json; charset=utf-8", "transfer-encoding": "chunked", "connection": "keep-alive", "expires": "Thu, 19 Nov 1981 08:52:00 GMT", "cache-control": "no-store, no-cache, must-revalidate", "pragma": "no-cache", "vary": "Accept-Encoding", "set-cookie": "PHPSESSID=epa1clm7qhu0t8bppv9kclfhj9; path=/", "access-control-allow-origin": "*", "x-powered-by": "PleskLin"} }
 TRACE my_mensa_lib > Text: "{\n    \"result\": [\n        {\n            \"tag\": {\n                \"timestamp\": 1692825930,\n                \"tag_formatiert\": \"Mi <small>(23.08.)<\\/small>\",\n                \"tag_formatiert2\": \"Mi, 23.08.2023\",\n                \"tag_formatiert_rel\": \"heute\",\n                \"jahrestag\": \"234\",\n                \"wochentag\": \"Mittwoch\",\n                \"wochentag_short\": \"Mi\",\n                \"datum\": \"23.08.\",\n                \"datum2\": \"23.08.\",\n                \"datum_iso\": \"2023-08-23\",\n                \"wota_index\": \"3\",\n                \"kw\": \"34\"\n            }\n        }\n    ],\n    \"mensaname\": \"Ulm, Universität, Cafeteria Uni West\"\n}"
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Failed to decode getdata response

Caused by:
    missing field `essen` at line 18 column 9', uulm_mensa_cli/src/main.rs:39:42

arguably a valid reason for panicing, but an explicit error would be nicer