better error on failure response
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 1m0s

This commit is contained in:
Max Känner 2025-01-09 22:09:35 +01:00
parent 43c1bff91f
commit 1f6ebfee2e
4 changed files with 440 additions and 180 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
.envrc
.direnv
/result
template.md

606
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package]
name = "vikunja-gatherer"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
[lints.clippy]

View File

@ -3,9 +3,10 @@ use std::{env, fs};
use camino::Utf8PathBuf;
use chrono::{Datelike, Utc};
use clap::Parser;
use color_eyre::eyre::{eyre, OptionExt, Result};
use color_eyre::eyre::{bail, eyre, OptionExt, Result};
use log::{debug, error, info};
use regex::Regex;
use reqwest::StatusCode;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
@ -88,6 +89,14 @@ fn main() -> Result<()> {
.send()?;
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");
let tasks = response.json::<Vec<Task>>()?;
debug!("got tasks: {tasks:#?}");