Skip to content
This repository was archived by the owner on Sep 1, 2023. It is now read-only.

Commit c5743e1

Browse files
fix(apps): handle 404 error (#11)
2 parents dab44a3 + 39effb3 commit c5743e1

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ version = "0.1.0-alpha"
44
edition = "2021"
55
description = "Blazingly fast Discloud CLI"
66
license = "Apache-2.0"
7-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
87

98
[dependencies]
109
clap = { version = "3.2.20", features = ["derive"] }

src/commands/apps.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
use colored::Colorize;
2+
3+
use crate::entities::FetchError;
24
pub fn apps() {
35
let token = super::expect_token();
46
match crate::entities::app::App::fetch_all(token.clone()) {
@@ -9,7 +11,21 @@ pub fn apps() {
911
}
1012
}
1113
Err(err) => {
12-
super::err(&err.to_string());
14+
match err {
15+
FetchError::APIReturnedError(code) =>{
16+
match code {
17+
404 => {
18+
super::err("You don't have any apps. Use `discloud up` to upload one.")
19+
}
20+
_ => {
21+
super::err(&err.to_string());
22+
}
23+
}
24+
}
25+
err => {
26+
super::err(&err.to_string());
27+
}
28+
}
1329
}
1430
}
1531
}

src/commands/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub fn ask_for_app(token: String, action: &str) -> Result<u128, FetchError> {
7676
let user = crate::entities::user::fetch_user(token.clone())?;
7777
match user.apps.len() {
7878
0 => {
79-
err("You don't have any app on discloud, use `discloud up` to upload an app.");
79+
err("You don't have any apps. Use `discloud up` to upload one.");
8080
std::process::exit(1)
8181
}
8282
1 => Ok(user.apps[0].parse().unwrap()),

0 commit comments

Comments
 (0)