Skip to content

Commit

Permalink
add custom errors compatible with std
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
Olivier committed Jan 4, 2025
1 parent bcdf5fc commit 5e1fe21
Show file tree
Hide file tree
Showing 5 changed files with 27 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
12 changes: 12 additions & 0 deletions opcua-core/src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use opcua_types::{Variant, VariantScalarTypeId};

Check failure on line 1 in opcua-core/src/errors.rs

View workflow job for this annotation

GitHub Actions / build-linux (stable)

unused imports: `VariantScalarTypeId` and `Variant`

Check failure on line 1 in opcua-core/src/errors.rs

View workflow job for this annotation

GitHub Actions / build-linux (beta)

unused imports: `VariantScalarTypeId` and `Variant`
use thiserror::Error;

/// Rust OpcUa specific errors
#[allow(missing_docs)]
#[derive(Error, Debug)]
pub enum OpcUAError {
#[error("Received an expected variant type")]
UnExpectedVariantType(Option<VariantScalarTypeId),

Check failure on line 9 in opcua-core/src/errors.rs

View workflow job for this annotation

GitHub Actions / build-linux (stable)

expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `)`

Check failure on line 9 in opcua-core/src/errors.rs

View workflow job for this annotation

GitHub Actions / build-linux (stable)

expected `,`

Check failure on line 9 in opcua-core/src/errors.rs

View workflow job for this annotation

GitHub Actions / build-linux (beta)

expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `)`

Check failure on line 9 in opcua-core/src/errors.rs

View workflow job for this annotation

GitHub Actions / build-linux (beta)

expected `,`
#[error("The requested namespace does not exists")]
NamespaceDoesNotExist(String),
}
3 changes: 3 additions & 0 deletions opcua-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ pub mod comms;
pub mod config;
pub mod handle;

/// Rust OpcUa specific errors
pub mod errors;

pub mod messages;
pub use messages::{Message, MessageType, RequestMessage, ResponseMessage};

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 5e1fe21

Please sign in to comment.