Skip to content

Commit

Permalink
Add custom errors compatible with std (#18)
Browse files Browse the repository at this point in the history
To be used for internal code and not abuse StatusCode errors from protocol
  • Loading branch information
oroulet authored Jan 5, 2025
1 parent bcdf5fc commit 931ffe2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions opcua-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ url = { workspace = true }

opcua-types = { path = "../opcua-types" }
opcua-crypto = { path = "../opcua-crypto" }
thiserror = { workspace = true }


[lints.rust]
Expand Down
17 changes: 17 additions & 0 deletions opcua-core/src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// OPCUA for Rust
// SPDX-License-Identifier: MPL-2.0

//! Rust OpcUa specific errors
use opcua_types::VariantScalarTypeId;
use thiserror::Error;

/// Rust OpcUa specific errors
#[allow(missing_docs)]
#[derive(Error, Debug)]
pub enum OpcUAError {
#[error("Received an unexpected variant type")]
UnexpectedVariantType(Option<VariantScalarTypeId>),
#[error("The requested namespace does not exists")]
NamespaceDoesNotExist(String),
}
1 change: 1 addition & 0 deletions opcua-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub mod constants {

pub mod comms;
pub mod config;
pub mod errors;
pub mod handle;

pub mod messages;
Expand Down
20 changes: 10 additions & 10 deletions samples/client.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ verify_server_certs: true
pki_dir: ./pki
preferred_locales: []
default_endpoint: sample_none
user_tokens:
sample_user:
user: sample1
password: sample1pwd
sample_user2:
user: sample2
password: sample2pwd
endpoints:
sample_basic128rsa15:
url: opc.tcp://127.0.0.1:4855/
Expand All @@ -37,6 +30,14 @@ endpoints:
security_policy: None
security_mode: None
user_token_id: ANONYMOUS
user_tokens:
sample_user:
user: sample1
password: sample1pwd
sample_user2:
user: sample2
password: sample2pwd
channel_lifetime: 60000
decoding_options:
max_message_size: 327675
max_chunk_count: 5
Expand Down Expand Up @@ -65,10 +66,9 @@ publish_timeout:
min_publish_interval:
secs: 0
nanos: 100000000
session_timeout: 60000
performance:
ignore_clock_skew: false
recreate_monitored_items_chunk: 1000
session_name: Rust OPC UA Client
channel_lifetime: 60000
recreate_subscriptions: true
session_name: Rust OPC UA Client
session_timeout: 60000

0 comments on commit 931ffe2

Please sign in to comment.