Skip to content

Commit 9ef85ef

Browse files
Ilia ZyrinIlia Zyrin
Ilia Zyrin
authored and
Ilia Zyrin
committed
add a debug config for VS Code and propagate errors
1 parent 510062c commit 9ef85ef

File tree

3 files changed

+49
-5
lines changed

3 files changed

+49
-5
lines changed

.vscode/launch.json

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "lldb",
9+
"request": "launch",
10+
"name": "Debug executable 'eva01'",
11+
"cargo": {
12+
"args": [
13+
"build",
14+
"--bin=eva01",
15+
"--package=eva01"
16+
],
17+
"filter": {
18+
"name": "eva01",
19+
"kind": "bin"
20+
}
21+
},
22+
"args": ["run", "cfg.toml"],
23+
"cwd": "${workspaceFolder}"
24+
},
25+
{
26+
"type": "lldb",
27+
"request": "launch",
28+
"name": "Debug unit tests in executable 'eva01'",
29+
"cargo": {
30+
"args": [
31+
"test",
32+
"--no-run",
33+
"--bin=eva01",
34+
"--package=eva01"
35+
],
36+
"filter": {
37+
"name": "eva01",
38+
"kind": "bin"
39+
}
40+
},
41+
"args": [],
42+
"cwd": "${workspaceFolder}"
43+
}
44+
]
45+
}

src/cli/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub async fn main_entry() -> anyhow::Result<()> {
1717

1818
match args.cmd {
1919
app::Commands::Run { path } => {
20-
let config = Eva01Config::try_load_from_file(path).unwrap();
20+
let config = Eva01Config::try_load_from_file(path)?;
2121
entrypoints::run_liquidator(config).await?;
2222
}
2323
app::Commands::Setup => {

src/config.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use fixed::types::I80F48;
1010
use fixed_macro::types::I80F48;
1111
use solana_sdk::{pubkey, pubkey::Pubkey};
1212
use std::{
13-
error::Error,
1413
io::{BufWriter, Write},
1514
path::PathBuf,
1615
};
@@ -25,11 +24,11 @@ pub struct Eva01Config {
2524
}
2625

2726
impl Eva01Config {
28-
pub fn try_load_from_file(path: PathBuf) -> Result<Self, Box<dyn Error>> {
27+
pub fn try_load_from_file(path: PathBuf) -> anyhow::Result<Self> {
2928
let config_str = std::fs::read_to_string(path)
30-
.map_err(|e| format!("Failed to read config file: {:?}", e))?;
29+
.map_err(|e| anyhow::anyhow!("Failed to read config file: {:#?}", e))?;
3130
let config = toml::from_str(&config_str)
32-
.map_err(|e| format!("Failed to parse config file {:?}", e))?;
31+
.map_err(|e| anyhow::anyhow!("Failed to parse config file {:#?}", e))?;
3332
Ok(config)
3433
}
3534

0 commit comments

Comments
 (0)