locka99 / opcua

A client and server implementation of the OPC UA specification written in Rust
Mozilla Public License 2.0
480 stars 129 forks source link

errors in configuration files are not reported #165

Closed lovasoa closed 2 years ago

lovasoa commented 2 years ago

When a configuration file cannot be deserialized, this is the only thing that is logged:

2022-02-21 17:55:37.608 - ERROR - opcua_core::config - Cannot deserialize configuration from ./server.conf

And the ServerConfig::load returns Err(()), so there is no way to know where the error is in the invalid configuration file.

locka99 commented 2 years ago

I'll check if there is any way to get meaningful errors out of serde but this is currently opaque - the code asks serde to load and it either does or it doesn't.

lovasoa commented 2 years ago

Yes, serde gives meaningful errors, that could be returned to the user, potentially wrapped in a custom error type. Also, serde_yaml can read a file directly, no need to read it to a string first: https://docs.rs/serde_yaml/latest/serde_yaml/fn.from_reader.html

locka99 commented 2 years ago

For now I've added code to log the error message that serde gives me into the error output