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
|
||||
.direnv
|
||||
/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]
|
||||
name = "vikunja-gatherer"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
|
||||
[lints.clippy]
|
||||
|
11
src/main.rs
11
src/main.rs
@ -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:#?}");
|
||||
|
Loading…
x
Reference in New Issue
Block a user