vkteams-bot 0.11.5

High-performance VK Teams Bot API toolkit with CLI and MCP server support
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
use serde::{Deserialize, Serialize};
use std::env::VarError;
use std::fmt;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApiError {
    pub description: String,
}

impl fmt::Display for ApiError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "API Error: {}", self.description)
    }
}

impl std::error::Error for ApiError {}

#[derive(Debug)]
pub struct OtlpError {
    pub message: String,
}

impl fmt::Display for OtlpError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.message)
    }
}

impl std::error::Error for OtlpError {}

impl From<String> for OtlpError {
    fn from(message: String) -> Self {
        OtlpError { message }
    }
}

impl From<Box<dyn std::error::Error>> for OtlpError {
    fn from(err: Box<dyn std::error::Error>) -> Self {
        OtlpError {
            message: err.to_string(),
        }
    }
}

#[derive(Debug)]
pub enum BotError {
    /// API Error
    Api(ApiError),
    /// Network Error
    Network(reqwest::Error),
    /// gRPC Error
    #[cfg(feature = "grpc")]
    Grpc(tonic::transport::Error),
    /// Serialization/Deserialization Error
    Serialization(serde_json::Error),
    /// URL Error
    Url(url::ParseError),
    /// File System Error
    Io(std::io::Error),
    /// Template Error
    #[cfg(feature = "templates")]
    Template(tera::Error),
    /// Configuration Error
    Config(String),
    /// Validation Error
    Validation(String),
    /// URL Parameters Error
    UrlParams(serde_url_params::Error),
    /// System Error
    System(String),
    /// Environment Error
    Environment(std::env::VarError),
    /// Otlp Error
    Otlp(OtlpError),
}

impl fmt::Display for BotError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            BotError::Api(e) => write!(f, "API Error: {e}"),
            BotError::Network(e) => write!(f, "Network Error: {e}"),
            #[cfg(feature = "grpc")]
            BotError::Grpc(e) => write!(f, "gRPC Error: {e}"),
            BotError::Serialization(e) => write!(f, "Serialization Error: {e}"),
            BotError::Url(e) => write!(f, "URL Error: {e}"),
            BotError::Io(e) => write!(f, "IO Error: {e}"),
            #[cfg(feature = "templates")]
            BotError::Template(e) => write!(f, "Template Error: {e}"),
            BotError::Config(e) => write!(f, "Config Error: {e}"),
            BotError::Validation(e) => write!(f, "Validation Error: {e}"),
            BotError::UrlParams(e) => write!(f, "URL Parameters Error: {e}"),
            BotError::System(e) => write!(f, "System Error: {e}"),
            BotError::Environment(e) => write!(f, "Environment Error: {e}"),
            BotError::Otlp(e) => write!(f, "Otlp Error: {e}"),
        }
    }
}

impl std::error::Error for BotError {
    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
        match self {
            BotError::Api(e) => Some(e),
            BotError::Network(e) => Some(e),
            #[cfg(feature = "grpc")]
            BotError::Grpc(e) => Some(e),
            BotError::Serialization(e) => Some(e),
            BotError::Url(e) => Some(e),
            BotError::Io(e) => Some(e),
            #[cfg(feature = "templates")]
            BotError::Template(e) => Some(e),
            BotError::Config(_) => None,
            BotError::Validation(_) => None,
            BotError::UrlParams(e) => Some(e),
            BotError::System(_) => None,
            BotError::Environment(e) => Some(e),
            BotError::Otlp(e) => Some(e),
        }
    }
}

impl From<reqwest::Error> for BotError {
    fn from(err: reqwest::Error) -> Self {
        BotError::Network(err)
    }
}

impl From<serde_json::Error> for BotError {
    fn from(err: serde_json::Error) -> Self {
        BotError::Serialization(err)
    }
}

impl From<url::ParseError> for BotError {
    fn from(err: url::ParseError) -> Self {
        BotError::Url(err)
    }
}

impl From<std::io::Error> for BotError {
    fn from(err: std::io::Error) -> Self {
        BotError::Io(err)
    }
}

#[cfg(feature = "templates")]
impl From<tera::Error> for BotError {
    fn from(err: tera::Error) -> Self {
        BotError::Template(err)
    }
}

impl From<serde_url_params::Error> for BotError {
    fn from(err: serde_url_params::Error) -> Self {
        BotError::UrlParams(err)
    }
}
#[cfg(feature = "grpc")]
impl From<tonic::transport::Error> for BotError {
    fn from(err: tonic::transport::Error) -> Self {
        BotError::Grpc(err)
    }
}

impl From<toml::de::Error> for BotError {
    fn from(err: toml::de::Error) -> Self {
        BotError::Config(err.to_string())
    }
}

impl From<VarError> for BotError {
    fn from(err: VarError) -> Self {
        BotError::Environment(err)
    }
}

impl From<ApiError> for BotError {
    fn from(err: ApiError) -> Self {
        BotError::Api(err)
    }
}

pub type Result<T> = std::result::Result<T, BotError>;

#[cfg(test)]
mod tests {
    use super::*;
    use serde_json;
    use url::ParseError;

    #[test]
    fn test_api_error_display() {
        let err = ApiError {
            description: "fail".to_string(),
        };
        assert_eq!(format!("{err}"), "API Error: fail");
    }

    #[test]
    fn test_otlp_error_display_and_from() {
        let err = OtlpError {
            message: "otlp fail".to_string(),
        };
        assert_eq!(format!("{err}"), "otlp fail");
        let from_str: OtlpError = "msg".to_string().into();
        assert_eq!(from_str.message, "msg");
        let boxed: OtlpError =
            Box::<dyn std::error::Error>::from(std::io::Error::other("err")).into();
        assert!(boxed.message.contains("err"));
    }

    #[test]
    fn test_bot_error_display_and_from() {
        let api = ApiError {
            description: "api".to_string(),
        };
        let err = BotError::Api(api.clone());
        assert!(format!("{err}").contains("API Error"));
        let ser = BotError::Serialization(serde_json::Error::io(std::io::Error::other("ser")));
        assert!(format!("{ser}").contains("Serialization Error"));
        let url = BotError::Url(ParseError::EmptyHost);
        assert!(format!("{url}").contains("URL Error"));
        let ioerr = BotError::Io(std::io::Error::other("io"));
        assert!(format!("{ioerr}").contains("IO Error"));
        let conf = BotError::Config("conf".to_string());
        assert!(format!("{conf}").contains("Config Error"));
        let val = BotError::Validation("val".to_string());
        assert!(format!("{val}").contains("Validation Error"));
        let sys = BotError::System("sys".to_string());
        assert!(format!("{sys}").contains("System Error"));
        let otlp = BotError::Otlp(OtlpError {
            message: "otlp".to_string(),
        });
        assert!(format!("{otlp}").contains("Otlp Error"));
    }

    #[test]
    fn test_bot_error_from_impls() {
        let _b: BotError = serde_json::Error::io(std::io::Error::other("ser")).into();
        let _b: BotError = url::ParseError::EmptyHost.into();
        let _b: BotError = std::io::Error::other("io").into();
        let _b: BotError = serde_url_params::Error::unsupported("params").into();
        let _b: BotError = toml::from_str::<i32>("not toml").unwrap_err().into();
        let _b: BotError = std::env::VarError::NotPresent.into();
        let _b: BotError = ApiError {
            description: "api".to_string(),
        }
        .into();
    }

    #[test]
    fn test_api_error_serialization() {
        let error = ApiError {
            description: "Test error message".to_string(),
        };

        // Test serialization
        let serialized = serde_json::to_string(&error).unwrap();
        assert!(serialized.contains("Test error message"));

        // Test deserialization
        let deserialized: ApiError = serde_json::from_str(&serialized).unwrap();
        assert_eq!(deserialized.description, "Test error message");
    }

    #[test]
    fn test_api_error_clone() {
        let error = ApiError {
            description: "Cloneable error".to_string(),
        };
        let cloned = error.clone();
        assert_eq!(error.description, cloned.description);
    }

    #[test]
    fn test_api_error_as_std_error() {
        let error = ApiError {
            description: "Standard error test".to_string(),
        };

        // Test that it implements std::error::Error
        let std_err: &dyn std::error::Error = &error;
        assert!(std_err.source().is_none());
    }

    #[test]
    fn test_otlp_error_from_box_error() {
        let io_error = std::io::Error::new(std::io::ErrorKind::PermissionDenied, "Access denied");
        let boxed: Box<dyn std::error::Error> = Box::new(io_error);
        let otlp_error: OtlpError = boxed.into();

        assert!(otlp_error.message.contains("Access denied"));
    }

    #[test]
    fn test_otlp_error_as_std_error() {
        let error = OtlpError {
            message: "OTLP connection failed".to_string(),
        };

        // Test that it implements std::error::Error
        let std_err: &dyn std::error::Error = &error;
        assert!(std_err.source().is_none());
    }

    #[tokio::test]
    async fn test_bot_error_source_chain() {
        use std::error::Error;

        // Test API error source
        let api_err = BotError::Api(ApiError {
            description: "API failed".to_string(),
        });
        assert!(api_err.source().is_some());

        // Test Network error source
        let network_err = BotError::Network(
            reqwest::ClientBuilder::new()
                .build()
                .unwrap()
                .get("http://invalid-url")
                .send()
                .await
                .unwrap_err(),
        );
        assert!(network_err.source().is_some());

        // Test Serialization error source
        let ser_err = BotError::Serialization(serde_json::Error::io(std::io::Error::other(
            "serialization",
        )));
        assert!(ser_err.source().is_some());

        // Test URL error source
        let url_err = BotError::Url(url::ParseError::EmptyHost);
        assert!(url_err.source().is_some());

        // Test IO error source
        let io_err = BotError::Io(std::io::Error::new(
            std::io::ErrorKind::NotFound,
            "file not found",
        ));
        assert!(io_err.source().is_some());

        // Test UrlParams error source
        let params_err = BotError::UrlParams(serde_url_params::Error::unsupported("test"));
        assert!(params_err.source().is_some());

        // Test OTLP error source
        let otlp_err = BotError::Otlp(OtlpError {
            message: "OTLP failed".to_string(),
        });
        assert!(otlp_err.source().is_some());

        // Test errors with no source
        let config_err = BotError::Config("Config error".to_string());
        assert!(config_err.source().is_none());

        let validation_err = BotError::Validation("Validation error".to_string());
        assert!(validation_err.source().is_none());

        let system_err = BotError::System("System error".to_string());
        assert!(system_err.source().is_none());
    }

    #[test]
    fn test_bot_error_debug_format() {
        let errors = vec![
            BotError::Api(ApiError {
                description: "Debug API error".to_string(),
            }),
            BotError::Config("Debug config error".to_string()),
            BotError::Validation("Debug validation error".to_string()),
            BotError::System("Debug system error".to_string()),
            BotError::Otlp(OtlpError {
                message: "Debug OTLP error".to_string(),
            }),
        ];

        for error in errors {
            let debug_str = error.to_string();
            assert!(!debug_str.is_empty());
            assert!(debug_str.contains("Error"));
        }
    }

    #[test]
    fn test_error_conversion_chain() {
        // Test VarError conversion chain
        let var_error = std::env::VarError::NotPresent;
        let bot_error: BotError = var_error.into();
        match bot_error {
            BotError::Environment(msg) => assert!(msg.to_string().contains("not found")),
            _ => panic!("Expected Config error"),
        }

        // Test TOML error conversion chain
        let toml_error = toml::from_str::<i32>("invalid toml").unwrap_err();
        let bot_error: BotError = toml_error.into();
        match bot_error {
            BotError::Config(_) => {} // Expected
            _ => panic!("Expected Config error"),
        }
    }

    #[tokio::test]
    async fn test_all_error_types_display() {
        let test_cases = vec![
            (
                BotError::Api(ApiError {
                    description: "API test".to_string(),
                }),
                "API Error",
            ),
            (
                BotError::Network(
                    reqwest::ClientBuilder::new()
                        .build()
                        .unwrap()
                        .get("http://test")
                        .send()
                        .await
                        .unwrap_err(),
                ),
                "Network Error",
            ),
            (
                BotError::Serialization(serde_json::Error::io(std::io::Error::other("test"))),
                "Serialization Error",
            ),
            (BotError::Url(url::ParseError::EmptyHost), "URL Error"),
            (BotError::Io(std::io::Error::other("test")), "IO Error"),
            (BotError::Config("test".to_string()), "Config Error"),
            (BotError::Validation("test".to_string()), "Validation Error"),
            (
                BotError::UrlParams(serde_url_params::Error::unsupported("test")),
                "URL Parameters Error",
            ),
            (BotError::System("test".to_string()), "System Error"),
            (
                BotError::Otlp(OtlpError {
                    message: "test".to_string(),
                }),
                "Otlp Error",
            ),
        ];

        for (error, expected_prefix) in test_cases {
            let display_str = format!("{error}");
            assert!(
                display_str.contains(expected_prefix),
                "Error '{display_str}' should contain '{expected_prefix}'"
            );
        }
    }

    #[cfg(feature = "templates")]
    #[test]
    fn test_template_error_conversion() {
        use tera::Tera;

        let tera = Tera::new("templates/*").unwrap_or_default();
        let template_error = tera
            .render("nonexistent", &tera::Context::new())
            .unwrap_err();
        let bot_error: BotError = template_error.into();

        match bot_error {
            BotError::Template(_) => {} // Expected
            _ => panic!("Expected Template error"),
        }

        let display_str = format!("{bot_error}");
        assert!(display_str.contains("Template Error"));
    }

    #[test]
    fn test_result_type_alias() {
        // Test that our Result type alias works correctly
        fn test_function() -> Result<String> {
            Ok("success".to_string())
        }

        fn test_error_function() -> Result<String> {
            Err(BotError::Validation("test error".to_string()))
        }

        assert!(test_function().is_ok());
        assert_eq!(test_function().unwrap(), "success");

        assert!(test_error_function().is_err());
        match test_error_function().unwrap_err() {
            BotError::Validation(msg) => assert_eq!(msg, "test error"),
            _ => panic!("Expected Validation error"),
        }
    }

    #[test]
    fn test_error_message_content() {
        // Test that error messages contain expected content
        let api_error = ApiError {
            description: "Specific API failure".to_string(),
        };
        assert!(format!("{api_error}").contains("Specific API failure"));

        let otlp_error = OtlpError {
            message: "OTLP connection timeout".to_string(),
        };
        assert!(format!("{otlp_error}").contains("OTLP connection timeout"));

        let config_error = BotError::Config("Missing required field".to_string());
        assert!(format!("{config_error}").contains("Missing required field"));
    }
}

#[test]
fn test_api_error_serialization() {
    let error = ApiError {
        description: "Test error message".to_string(),
    };

    // Test serialization
    let serialized = serde_json::to_string(&error).unwrap();
    assert!(serialized.contains("Test error message"));

    // Test deserialization
    let deserialized: ApiError = serde_json::from_str(&serialized).unwrap();
    assert_eq!(deserialized.description, "Test error message");
}

#[test]
fn test_api_error_clone() {
    let error = ApiError {
        description: "Cloneable error".to_string(),
    };
    let cloned = error.clone();
    assert_eq!(error.description, cloned.description);
}

#[test]
fn test_api_error_as_std_error() {
    let error = ApiError {
        description: "Standard error test".to_string(),
    };

    // Test that it implements std::error::Error
    let std_err: &dyn std::error::Error = &error;
    assert!(std_err.source().is_none());
}

#[test]
fn test_otlp_error_from_box_error() {
    let io_error = std::io::Error::new(std::io::ErrorKind::PermissionDenied, "Access denied");
    let boxed: Box<dyn std::error::Error> = Box::new(io_error);
    let otlp_error: OtlpError = boxed.into();

    assert!(otlp_error.message.contains("Access denied"));
}

#[test]
fn test_otlp_error_as_std_error() {
    let error = OtlpError {
        message: "OTLP connection failed".to_string(),
    };

    // Test that it implements std::error::Error
    let std_err: &dyn std::error::Error = &error;
    assert!(std_err.source().is_none());
}

#[tokio::test]
async fn test_bot_error_source_chain() {
    use std::error::Error;
    // Test API error source
    let api_err = BotError::Api(ApiError {
        description: "API failed".to_string(),
    });
    assert!(api_err.source().is_some());

    // Test Network error source
    let network_err = BotError::Network(
        reqwest::ClientBuilder::new()
            .build()
            .unwrap()
            .get("http://invalid-url")
            .send()
            .await
            .unwrap_err(),
    );
    assert!(network_err.source().is_some());

    // Test Serialization error source
    let ser_err = BotError::Serialization(serde_json::Error::io(std::io::Error::other(
        "serialization",
    )));
    assert!(ser_err.source().is_some());

    // Test URL error source
    let url_err = BotError::Url(url::ParseError::EmptyHost);
    assert!(url_err.source().is_some());

    // Test IO error source
    let io_err = BotError::Io(std::io::Error::new(
        std::io::ErrorKind::NotFound,
        "file not found",
    ));
    assert!(io_err.source().is_some());

    // Test UrlParams error source
    let params_err = BotError::UrlParams(serde_url_params::Error::unsupported("test"));
    assert!(params_err.source().is_some());

    // Test OTLP error source
    let otlp_err = BotError::Otlp(OtlpError {
        message: "OTLP failed".to_string(),
    });
    assert!(otlp_err.source().is_some());

    // Test errors with no source
    let config_err = BotError::Config("Config error".to_string());
    assert!(config_err.source().is_none());

    let validation_err = BotError::Validation("Validation error".to_string());
    assert!(validation_err.source().is_none());

    let system_err = BotError::System("System error".to_string());
    assert!(system_err.source().is_none());
}

#[test]
fn test_bot_error_debug_format() {
    let errors = vec![
        BotError::Api(ApiError {
            description: "Debug API error".to_string(),
        }),
        BotError::Config("Debug config error".to_string()),
        BotError::Validation("Debug validation error".to_string()),
        BotError::System("Debug system error".to_string()),
        BotError::Otlp(OtlpError {
            message: "Debug OTLP error".to_string(),
        }),
    ];

    for error in errors {
        let debug_str = error.to_string();
        assert!(!debug_str.is_empty());
        assert!(debug_str.contains("Error"));
    }
}

#[test]
fn test_error_conversion_chain() {
    // Test VarError conversion chain
    let var_error = std::env::VarError::NotPresent;
    let bot_error: BotError = var_error.into();
    match bot_error {
        BotError::Environment(msg) => assert!(msg.to_string().contains("not found")),
        _ => panic!("Expected Config error"),
    }

    // Test TOML error conversion chain
    let toml_error = toml::from_str::<i32>("invalid toml").unwrap_err();
    let bot_error: BotError = toml_error.into();
    match bot_error {
        BotError::Config(_) => {} // Expected
        _ => panic!("Expected Config error"),
    }
}

#[tokio::test]
async fn test_all_error_types_display() {
    let test_cases = vec![
        (
            BotError::Api(ApiError {
                description: "API test".to_string(),
            }),
            "API Error",
        ),
        (
            BotError::Network(
                reqwest::ClientBuilder::new()
                    .build()
                    .unwrap()
                    .get("http://test")
                    .send()
                    .await
                    .unwrap_err(),
            ),
            "Network Error",
        ),
        (
            BotError::Serialization(serde_json::Error::io(std::io::Error::other("test"))),
            "Serialization Error",
        ),
        (BotError::Url(url::ParseError::EmptyHost), "URL Error"),
        (BotError::Io(std::io::Error::other("test")), "IO Error"),
        (BotError::Config("test".to_string()), "Config Error"),
        (BotError::Validation("test".to_string()), "Validation Error"),
        (
            BotError::UrlParams(serde_url_params::Error::unsupported("test")),
            "URL Parameters Error",
        ),
        (BotError::System("test".to_string()), "System Error"),
        (
            BotError::Otlp(OtlpError {
                message: "test".to_string(),
            }),
            "Otlp Error",
        ),
    ];

    for (error, expected_prefix) in test_cases {
        let display_str = format!("{error}");
        assert!(
            display_str.contains(expected_prefix),
            "Error '{display_str}' should contain '{expected_prefix}'"
        );
    }
}

#[cfg(feature = "templates")]
#[test]
fn test_template_error_conversion() {
    use tera::Tera;

    let tera = Tera::new("templates/*").unwrap_or_default();
    let template_error = tera
        .render("nonexistent", &tera::Context::new())
        .unwrap_err();
    let bot_error: BotError = template_error.into();

    match bot_error {
        BotError::Template(_) => {} // Expected
        _ => panic!("Expected Template error"),
    }

    let display_str = format!("{bot_error}");
    assert!(display_str.contains("Template Error"));
}

#[test]
fn test_result_type_alias() {
    // Test that our Result type alias works correctly
    fn test_function() -> Result<String> {
        Ok("success".to_string())
    }

    fn test_error_function() -> Result<String> {
        Err(BotError::Validation("test error".to_string()))
    }

    assert!(test_function().is_ok());
    assert_eq!(test_function().unwrap(), "success");

    assert!(test_error_function().is_err());
    match test_error_function().unwrap_err() {
        BotError::Validation(msg) => assert_eq!(msg, "test error"),
        _ => panic!("Expected Validation error"),
    }
}

#[test]
fn test_error_message_content() {
    // Test that error messages contain expected content
    let api_error = ApiError {
        description: "Specific API failure".to_string(),
    };
    assert!(format!("{api_error}").contains("Specific API failure"));

    let otlp_error = OtlpError {
        message: "OTLP connection timeout".to_string(),
    };
    assert!(format!("{otlp_error}").contains("OTLP connection timeout"));

    let config_error = BotError::Config("Missing required field".to_string());
    assert!(format!("{config_error}").contains("Missing required field"));
}