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