mirror of
https://github.com/pcvolkmer/osc-variant.git
synced 2025-04-20 20:26:50 +00:00
Show additional information on parsing error
This commit is contained in:
parent
db7a3e6bfa
commit
1d37ae9295
10
src/main.rs
10
src/main.rs
@ -49,15 +49,17 @@ fn main() {
|
|||||||
let contents =
|
let contents =
|
||||||
fs::read_to_string(inputfile).expect("Should have been able to read the file");
|
fs::read_to_string(inputfile).expect("Should have been able to read the file");
|
||||||
|
|
||||||
if let Ok(data) = from_str::<OnkostarEditor>(contents.as_str()) {
|
match OnkostarEditor::from_str(contents.as_str()) {
|
||||||
data.list_forms()
|
Ok(data) => data.list_forms(),
|
||||||
} else {
|
Err(err) => {
|
||||||
eprintln!("Kann Eingabedatei nicht lesen!");
|
eprintln!("Kann Eingabedatei nicht lesen!");
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"Die Datei ist entweder keine OSC-Datei, fehlerhaft oder enthält zusätzliche Inhalte."
|
"Die Datei ist entweder keine OSC-Datei, fehlerhaft oder enthält zusätzliche Inhalte:\n{}",
|
||||||
|
err
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Command::Modify {
|
Command::Modify {
|
||||||
inputfile,
|
inputfile,
|
||||||
profile,
|
profile,
|
||||||
|
@ -23,7 +23,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use console::style;
|
use console::style;
|
||||||
|
use quick_xml::de::from_str;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
use crate::model::data_catalogue::DataCatalogue;
|
use crate::model::data_catalogue::DataCatalogue;
|
||||||
use crate::model::data_form::DataForm;
|
use crate::model::data_form::DataForm;
|
||||||
@ -96,6 +98,17 @@ impl OnkostarEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl FromStr for OnkostarEditor {
|
||||||
|
type Err = String;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
match from_str::<OnkostarEditor>(s) {
|
||||||
|
Ok(profile) => Ok(profile),
|
||||||
|
Err(err) => Err(err.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct InfoXML {
|
pub struct InfoXML {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user