better error on failure response
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 1m0s
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 1m0s
This commit is contained in:
parent
43c1bff91f
commit
1f6ebfee2e
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
|||||||
.envrc
|
.envrc
|
||||||
.direnv
|
.direnv
|
||||||
/result
|
/result
|
||||||
|
template.md
|
||||||
|
606
Cargo.lock
generated
606
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "vikunja-gatherer"
|
name = "vikunja-gatherer"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[lints.clippy]
|
[lints.clippy]
|
||||||
|
11
src/main.rs
11
src/main.rs
@ -3,9 +3,10 @@ use std::{env, fs};
|
|||||||
use camino::Utf8PathBuf;
|
use camino::Utf8PathBuf;
|
||||||
use chrono::{Datelike, Utc};
|
use chrono::{Datelike, Utc};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use color_eyre::eyre::{eyre, OptionExt, Result};
|
use color_eyre::eyre::{bail, eyre, OptionExt, Result};
|
||||||
use log::{debug, error, info};
|
use log::{debug, error, info};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
use reqwest::StatusCode;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
@ -88,6 +89,14 @@ fn main() -> Result<()> {
|
|||||||
.send()?;
|
.send()?;
|
||||||
debug!("got response: {response:?}");
|
debug!("got response: {response:?}");
|
||||||
|
|
||||||
|
if response.status() != StatusCode::OK {
|
||||||
|
error!("Request to Vikunja failed!");
|
||||||
|
let status = response.status();
|
||||||
|
let body_text = response.text()?;
|
||||||
|
info!("{}", body_text);
|
||||||
|
bail!("Vikunja request failed {}: {}", status, body_text)
|
||||||
|
}
|
||||||
|
|
||||||
info!("searching for the correct task");
|
info!("searching for the correct task");
|
||||||
let tasks = response.json::<Vec<Task>>()?;
|
let tasks = response.json::<Vec<Task>>()?;
|
||||||
debug!("got tasks: {tasks:#?}");
|
debug!("got tasks: {tasks:#?}");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user