Merge pull request #144 from rleungx/improve-error-messages
improve the error messages
This commit is contained in:
commit
041de8082a
|
@ -62,4 +62,4 @@ matches = "^0.1.6"
|
||||||
byteorder = "^1.2.1"
|
byteorder = "^1.2.1"
|
||||||
libc = "^0.2.1"
|
libc = "^0.2.1"
|
||||||
getopts = "^0.2"
|
getopts = "^0.2"
|
||||||
|
isatty = "0.1"
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
|
extern crate isatty;
|
||||||
extern crate rayon;
|
extern crate rayon;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
extern crate solana;
|
extern crate solana;
|
||||||
|
|
||||||
use getopts::Options;
|
use getopts::Options;
|
||||||
|
use isatty::stdin_isatty;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use solana::accountant_stub::AccountantStub;
|
use solana::accountant_stub::AccountantStub;
|
||||||
use solana::mint::Mint;
|
use solana::mint::Mint;
|
||||||
use solana::signature::{KeyPair, KeyPairUtil};
|
use solana::signature::{KeyPair, KeyPairUtil};
|
||||||
use solana::transaction::Transaction;
|
use solana::transaction::Transaction;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::io::stdin;
|
use std::io::{stdin, Read};
|
||||||
use std::net::UdpSocket;
|
use std::net::UdpSocket;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
|
@ -58,7 +60,20 @@ fn main() {
|
||||||
if matches.opt_present("t") {
|
if matches.opt_present("t") {
|
||||||
threads = matches.opt_str("t").unwrap().parse().expect("integer");
|
threads = matches.opt_str("t").unwrap().parse().expect("integer");
|
||||||
}
|
}
|
||||||
let mint: Mint = serde_json::from_reader(stdin()).unwrap_or_else(|e| {
|
|
||||||
|
if stdin_isatty() {
|
||||||
|
eprintln!("nothing found on stdin, expected a json file");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut buffer = String::new();
|
||||||
|
let num_bytes = stdin().read_to_string(&mut buffer).unwrap();
|
||||||
|
if num_bytes == 0 {
|
||||||
|
eprintln!("empty file on stdin, expected a json file");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mint: Mint = serde_json::from_str(&buffer).unwrap_or_else(|e| {
|
||||||
eprintln!("failed to parse json: {}", e);
|
eprintln!("failed to parse json: {}", e);
|
||||||
exit(1);
|
exit(1);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
|
extern crate isatty;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
extern crate solana;
|
extern crate solana;
|
||||||
|
|
||||||
|
use isatty::stdin_isatty;
|
||||||
use solana::entry::create_entry;
|
use solana::entry::create_entry;
|
||||||
use solana::event::Event;
|
use solana::event::Event;
|
||||||
use solana::hash::Hash;
|
use solana::hash::Hash;
|
||||||
use solana::mint::Mint;
|
use solana::mint::Mint;
|
||||||
use solana::signature::{KeyPair, KeyPairUtil, PublicKey};
|
use solana::signature::{KeyPair, KeyPairUtil, PublicKey};
|
||||||
use solana::transaction::Transaction;
|
use solana::transaction::Transaction;
|
||||||
use std::io::stdin;
|
use std::io::{stdin, Read};
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
fn transfer(from: &KeyPair, (to, tokens): (PublicKey, i64), last_id: Hash) -> Event {
|
fn transfer(from: &KeyPair, (to, tokens): (PublicKey, i64), last_id: Hash) -> Event {
|
||||||
|
@ -15,7 +17,19 @@ fn transfer(from: &KeyPair, (to, tokens): (PublicKey, i64), last_id: Hash) -> Ev
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mint: Mint = serde_json::from_reader(stdin()).unwrap_or_else(|e| {
|
if stdin_isatty() {
|
||||||
|
eprintln!("nothing found on stdin, expected a json file");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut buffer = String::new();
|
||||||
|
let num_bytes = stdin().read_to_string(&mut buffer).unwrap();
|
||||||
|
if num_bytes == 0 {
|
||||||
|
eprintln!("empty file on stdin, expected a json file");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mint: Mint = serde_json::from_str(&buffer).unwrap_or_else(|e| {
|
||||||
eprintln!("failed to parse json: {}", e);
|
eprintln!("failed to parse json: {}", e);
|
||||||
exit(1);
|
exit(1);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,14 +1,28 @@
|
||||||
//! A command-line executable for generating the chain's genesis block.
|
//! A command-line executable for generating the chain's genesis block.
|
||||||
|
|
||||||
|
extern crate isatty;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
extern crate solana;
|
extern crate solana;
|
||||||
|
|
||||||
|
use isatty::stdin_isatty;
|
||||||
use solana::mint::Mint;
|
use solana::mint::Mint;
|
||||||
use std::io::stdin;
|
use std::io::{stdin, Read};
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mint: Mint = serde_json::from_reader(stdin()).unwrap_or_else(|e| {
|
if stdin_isatty() {
|
||||||
|
eprintln!("nothing found on stdin, expected a json file");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut buffer = String::new();
|
||||||
|
let num_bytes = stdin().read_to_string(&mut buffer).unwrap();
|
||||||
|
if num_bytes == 0 {
|
||||||
|
eprintln!("empty file on stdin, expected a json file");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mint: Mint = serde_json::from_str(&buffer).unwrap_or_else(|e| {
|
||||||
eprintln!("failed to parse json: {}", e);
|
eprintln!("failed to parse json: {}", e);
|
||||||
exit(1);
|
exit(1);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,16 +1,25 @@
|
||||||
|
extern crate isatty;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
extern crate solana;
|
extern crate solana;
|
||||||
|
|
||||||
|
use isatty::stdin_isatty;
|
||||||
use solana::mint::Mint;
|
use solana::mint::Mint;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut input_text = String::new();
|
let mut input_text = String::new();
|
||||||
|
if stdin_isatty() {
|
||||||
|
eprintln!("nothing found on stdin, expected a token number");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
io::stdin().read_line(&mut input_text).unwrap();
|
io::stdin().read_line(&mut input_text).unwrap();
|
||||||
let trimmed = input_text.trim();
|
let trimmed = input_text.trim();
|
||||||
let tokens = trimmed.parse::<i64>().unwrap();
|
let tokens = trimmed.parse::<i64>().unwrap_or_else(|e| {
|
||||||
|
eprintln!("{}", e);
|
||||||
|
exit(1);
|
||||||
|
});
|
||||||
let mint = Mint::new(tokens);
|
let mint = Mint::new(tokens);
|
||||||
let serialized = serde_json::to_string(&mint).unwrap_or_else(|e| {
|
let serialized = serde_json::to_string(&mint).unwrap_or_else(|e| {
|
||||||
eprintln!("failed to serialize: {}", e);
|
eprintln!("failed to serialize: {}", e);
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
extern crate env_logger;
|
extern crate env_logger;
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
|
extern crate isatty;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
extern crate solana;
|
extern crate solana;
|
||||||
|
|
||||||
use getopts::Options;
|
use getopts::Options;
|
||||||
|
use isatty::stdin_isatty;
|
||||||
use solana::accountant::Accountant;
|
use solana::accountant::Accountant;
|
||||||
use solana::accountant_skel::AccountantSkel;
|
use solana::accountant_skel::AccountantSkel;
|
||||||
use solana::entry::Entry;
|
use solana::entry::Entry;
|
||||||
use solana::event::Event;
|
use solana::event::Event;
|
||||||
use solana::historian::Historian;
|
use solana::historian::Historian;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::io::{self, stdout, BufRead};
|
use std::io::{stdin, stdout, Read};
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
@ -47,9 +49,21 @@ fn main() {
|
||||||
port = matches.opt_str("p").unwrap().parse().expect("port");
|
port = matches.opt_str("p").unwrap().parse().expect("port");
|
||||||
}
|
}
|
||||||
let addr = format!("0.0.0.0:{}", port);
|
let addr = format!("0.0.0.0:{}", port);
|
||||||
let stdin = io::stdin();
|
|
||||||
let mut entries = stdin.lock().lines().map(|line| {
|
if stdin_isatty() {
|
||||||
serde_json::from_str(&line.unwrap()).unwrap_or_else(|e| {
|
eprintln!("nothing found on stdin, expected a log file");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut buffer = String::new();
|
||||||
|
let num_bytes = stdin().read_to_string(&mut buffer).unwrap();
|
||||||
|
if num_bytes == 0 {
|
||||||
|
eprintln!("empty file on stdin, expected a log file");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut entries = buffer.lines().map(|line| {
|
||||||
|
serde_json::from_str(&line).unwrap_or_else(|e| {
|
||||||
eprintln!("failed to parse json: {}", e);
|
eprintln!("failed to parse json: {}", e);
|
||||||
exit(1);
|
exit(1);
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,6 +4,8 @@ pub mod accountant_skel;
|
||||||
pub mod accountant_stub;
|
pub mod accountant_stub;
|
||||||
pub mod ecdsa;
|
pub mod ecdsa;
|
||||||
pub mod entry;
|
pub mod entry;
|
||||||
|
#[cfg(feature = "erasure")]
|
||||||
|
pub mod erasure;
|
||||||
pub mod event;
|
pub mod event;
|
||||||
pub mod hash;
|
pub mod hash;
|
||||||
pub mod historian;
|
pub mod historian;
|
||||||
|
@ -17,8 +19,6 @@ pub mod signature;
|
||||||
pub mod streamer;
|
pub mod streamer;
|
||||||
pub mod subscribers;
|
pub mod subscribers;
|
||||||
pub mod transaction;
|
pub mod transaction;
|
||||||
#[cfg(feature = "erasure")]
|
|
||||||
pub mod erasure;
|
|
||||||
extern crate bincode;
|
extern crate bincode;
|
||||||
extern crate byteorder;
|
extern crate byteorder;
|
||||||
extern crate chrono;
|
extern crate chrono;
|
||||||
|
|
Loading…
Reference in New Issue