Skip to content

Commit 94ba51d

Browse files
feat: improve uninformative error messages (#10201)
* feat: improve uninformative error messages * Update dispatcher.rs * Update dispatcher.rs * Update dispatcher.rs --------- Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com>
1 parent dc9ff38 commit 94ba51d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

crates/chisel/src/dispatcher.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,10 @@ impl ChiselDispatcher {
258258
self.session.id.as_ref().unwrap()
259259
)))
260260
} else {
261-
DispatchResult::CommandFailed(Self::make_error("Too many arguments supplied!"))
261+
DispatchResult::CommandFailed(Self::make_error(format!(
262+
"Too many arguments supplied: [{}]. Please check command syntax.",
263+
args.join(", ")
264+
)))
262265
}
263266
}
264267
ChiselCommand::Load => {
@@ -333,7 +336,9 @@ impl ChiselDispatcher {
333336
self.session.id = None;
334337
DispatchResult::CommandSuccess(Some(String::from("Cleared chisel cache!")))
335338
}
336-
Err(_) => DispatchResult::CommandFailed(Self::make_error("Failed to clear cache!")),
339+
Err(_) => DispatchResult::CommandFailed(Self::make_error(
340+
"Failed to clear cache! Check file permissions or disk space.",
341+
)),
337342
},
338343
ChiselCommand::Fork => {
339344
if args.is_empty() || args[0].trim().is_empty() {
@@ -371,7 +376,9 @@ impl ChiselDispatcher {
371376

372377
// Check validity of URL
373378
if Url::parse(&fork_url).is_err() {
374-
return DispatchResult::CommandFailed(Self::make_error("Invalid fork URL!"))
379+
return DispatchResult::CommandFailed(Self::make_error(
380+
"Invalid fork URL! Please provide a valid RPC endpoint URL.",
381+
))
375382
}
376383

377384
// Create success message before moving the fork_url
@@ -634,7 +641,9 @@ impl ChiselDispatcher {
634641
}
635642
ChiselCommand::Exec => {
636643
if args.is_empty() {
637-
return DispatchResult::CommandFailed(Self::make_error("No command supplied!"))
644+
return DispatchResult::CommandFailed(Self::make_error(
645+
"No command supplied! Please provide a valid command after '!'.",
646+
))
638647
}
639648

640649
let mut cmd = Command::new(args[0]);

0 commit comments

Comments
 (0)