aboutsummaryrefslogtreecommitdiffstats
path: root/src/github.rs
diff options
context:
space:
mode:
authorTeddy Wing2021-05-30 16:06:41 +0200
committerTeddy Wing2021-05-30 16:06:41 +0200
commitd071c5e456367ed0cc4f907e9e5c7dc46c331399 (patch)
tree9e8d72f87baf39f59d9e148da99b07f1cda84973 /src/github.rs
parent7d61e57aa6a7f3e61eb4ceac2b6fd7104245c3fe (diff)
downloadreflectub-d071c5e456367ed0cc4f907e9e5c7dc46c331399.tar.bz2
Replace boxed errors with concrete error types
Diffstat (limited to 'src/github.rs')
-rw-r--r--src/github.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/github.rs b/src/github.rs
index 8c853da..0b20abd 100644
--- a/src/github.rs
+++ b/src/github.rs
@@ -1,5 +1,6 @@
use reqwest::blocking::ClientBuilder;
use serde::Deserialize;
+use thiserror;
const USER_AGENT: &'static str = concat!(
@@ -9,6 +10,16 @@ const USER_AGENT: &'static str = concat!(
);
+#[derive(Debug, thiserror::Error)]
+pub enum Error {
+ #[error("request error")]
+ Http(#[from] reqwest::Error),
+
+ #[error("request header error")]
+ Header(#[from] reqwest::header::InvalidHeaderValue),
+}
+
+
#[derive(Debug, Deserialize)]
pub struct Repo {
pub id: i64,
@@ -21,7 +32,7 @@ pub struct Repo {
}
-pub fn fetch_repos() -> Result<Vec<Repo>, Box<dyn std::error::Error>> {
+pub fn fetch_repos() -> Result<Vec<Repo>, Error> {
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("Accept", "application/vnd.github.v3+json".parse()?);