[#9] Added general error module

This commit is contained in:
Jef Roosens 2021-04-04 13:03:08 +02:00
parent a80774b341
commit eab31e5e91
Signed by: Jef Roosens
GPG key ID: B580B976584B5F30
4 changed files with 29 additions and 5 deletions

View file

@ -1,3 +1,4 @@
use crate::errors::FejError;
use regex::Regex;
use reqwest::blocking as reqwest;
use rocket::http::RawStr;
@ -73,7 +74,7 @@ pub struct Street {
/// * `street` - name of the street
/// * `city` - city the street is in
// TODO find out how to do this async
pub fn search_streets(street_name: &String) -> Result<Vec<Street>, Box<dyn Error>> {
pub fn search_streets(street_name: &String) -> Result<Vec<Street>, FejError> {
let client = reqwest::Client::new();
let response = client.get(SEARCH_URL).query(&[("q", street_name)]).send()?;
let data: Vec<HashMap<String, String>> = response.json()?;