Improved Error Message Syntax

This commit is contained in:
Neshura 2024-03-04 16:43:06 +01:00
parent 49b8d8cc05
commit 04a1be9bcb
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C

View file

@ -64,7 +64,7 @@ impl CloudflareZone {
let entries = match response.json::<CloudflareApiResults>() { let entries = match response.json::<CloudflareApiResults>() {
Ok(data) => data, Ok(data) => data,
Err(e) => { Err(e) => {
let err_msg = format!("Unable to parse API response. Error: {e}"); let err_msg = format!("Unable to parse API response: {e}");
match connected_to_journal() { match connected_to_journal() {
true => error!("[ERROR] {err_msg}"), true => error!("[ERROR] {err_msg}"),
false => eprintln!("[ERROR] {err_msg}"), false => eprintln!("[ERROR] {err_msg}"),
@ -75,7 +75,7 @@ impl CloudflareZone {
Ok(entries.result) Ok(entries.result)
} else { } else {
let err_msg = format!("Unable to fetch Cloudflare Zone Entries for {}. Error: {}",self.name ,response.status()); let err_msg = format!("Unable to fetch Cloudflare Zone Entries for {}: {}",self.name ,response.status());
match connected_to_journal() { match connected_to_journal() {
true => error!("[ERROR] {err_msg}"), true => error!("[ERROR] {err_msg}"),
false => eprintln!("[ERROR] {err_msg}"), false => eprintln!("[ERROR] {err_msg}"),
@ -84,7 +84,7 @@ impl CloudflareZone {
} }
} }
Err(e) => { Err(e) => {
let err_msg = format!("Unable to access Cloudflare API. Error: {e}"); let err_msg = format!("Unable to access Cloudflare API: {e}");
match connected_to_journal() { match connected_to_journal() {
true => error!("[ERROR] {err_msg}"), true => error!("[ERROR] {err_msg}"),
false => eprintln!("[ERROR] {err_msg}"), false => eprintln!("[ERROR] {err_msg}"),
@ -107,7 +107,7 @@ impl CloudflareZone {
self.validate_response(response) self.validate_response(response)
}, },
Err(e) => { Err(e) => {
let err_msg = format!("Unable to access Cloudflare API. Error: {e}"); let err_msg = format!("Unable to access Cloudflare API: {e}");
match connected_to_journal() { match connected_to_journal() {
true => error!("[ERROR] {err_msg}"), true => error!("[ERROR] {err_msg}"),
false => eprintln!("[ERROR] {err_msg}"), false => eprintln!("[ERROR] {err_msg}"),
@ -133,7 +133,7 @@ impl CloudflareZone {
self.validate_response(response) self.validate_response(response)
}, },
Err(e) => { Err(e) => {
let err_msg = format!("Unable to access Cloudflare API. Error: {e}"); let err_msg = format!("Unable to access Cloudflare API: {e}");
match connected_to_journal() { match connected_to_journal() {
true => error!("[ERROR] {err_msg}"), true => error!("[ERROR] {err_msg}"),
false => eprintln!("[ERROR] {err_msg}"), false => eprintln!("[ERROR] {err_msg}"),
@ -174,7 +174,7 @@ impl CloudflareZone {
self.validate_response(response) self.validate_response(response)
}, },
Err(e) => { Err(e) => {
let err_msg = format!("Unable to access Cloudflare API. Error: {e}"); let err_msg = format!("Unable to access Cloudflare API: {e}");
match connected_to_journal() { match connected_to_journal() {
true => error!("[ERROR] {err_msg}"), true => error!("[ERROR] {err_msg}"),
false => eprintln!("[ERROR] {err_msg}"), false => eprintln!("[ERROR] {err_msg}"),
@ -200,7 +200,7 @@ impl CloudflareZone {
self.validate_response(response) self.validate_response(response)
}, },
Err(e) => { Err(e) => {
let err_msg = format!("Unable to access Cloudflare API. Error: {e}"); let err_msg = format!("Unable to access Cloudflare API: {e}");
match connected_to_journal() { match connected_to_journal() {
true => error!("[ERROR] {err_msg}"), true => error!("[ERROR] {err_msg}"),
false => eprintln!("[ERROR] {err_msg}"), false => eprintln!("[ERROR] {err_msg}"),
@ -270,7 +270,7 @@ impl CloudflareZone {
match Url::parse(input) { match Url::parse(input) {
Ok(url) => Ok(url), Ok(url) => Ok(url),
Err(e) => { Err(e) => {
let err_msg = format!("Unable to parse URL. Error: {}", e); let err_msg = format!("Unable to parse URL: {}", e);
match connected_to_journal() { match connected_to_journal() {
true => error!("[ERROR] {err_msg}"), true => error!("[ERROR] {err_msg}"),
false => eprintln!("[ERROR] {err_msg}"), false => eprintln!("[ERROR] {err_msg}"),
@ -293,7 +293,7 @@ impl CloudflareZone {
let data = match response.json::<CloudflareApiResult>() { let data = match response.json::<CloudflareApiResult>() {
Ok(data) => data, Ok(data) => data,
Err(e) => { Err(e) => {
let err_msg = format!("Unable to parse API response. Error: {e}"); let err_msg = format!("Unable to parse API response: {e}");
match connected_to_journal() { match connected_to_journal() {
true => error!("[ERROR] {err_msg}"), true => error!("[ERROR] {err_msg}"),
false => eprintln!("[ERROR] {err_msg}"), false => eprintln!("[ERROR] {err_msg}"),
@ -305,7 +305,7 @@ impl CloudflareZone {
match data.success { match data.success {
true => Ok(()), true => Ok(()),
false => { false => {
let err_msg = format!("Unexpected error while updating DNS record. Info: {:?}", data); let err_msg = format!("Unexpected error while updating DNS record: {:?}", data);
match connected_to_journal() { match connected_to_journal() {
true => error!("[ERROR] {err_msg}"), true => error!("[ERROR] {err_msg}"),
false => eprintln!("[ERROR] {err_msg}"), false => eprintln!("[ERROR] {err_msg}"),
@ -314,7 +314,7 @@ impl CloudflareZone {
} }
} }
} else { } else {
let err_msg = format!("Unable to post/put Cloudflare DNS entry. Error: {}", response.status()); let err_msg = format!("Unable to post/put Cloudflare DNS entry: {}", response.status());
match connected_to_journal() { match connected_to_journal() {
true => error!("[ERROR] {err_msg}"), true => error!("[ERROR] {err_msg}"),
false => eprintln!("[ERROR] {err_msg}"), false => eprintln!("[ERROR] {err_msg}"),