Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
feat(broker.rs): log underlying errors when running an adapter fail
Lars Wirzenius committed 2 years ago
commit d4ab0af114bba5286f3818746d1f9a17cc8a5d0c
parent 742824f07dc093dc8b7289b5e55d29dc43f84e29
1 file changed +8 -1
modified src/broker.rs
@@ -3,7 +3,7 @@
//! This is type and module of its own to facilitate automated
//! testing.

-
use std::{collections::HashMap, path::Path};
+
use std::{collections::HashMap, error::Error, path::Path};

use log::{debug, error, info};
use time::{macros::format_description, OffsetDateTime};
@@ -108,6 +108,11 @@ impl Broker {
                    debug!("broker runs adapter");
                    if let Err(e) = adapter.run(trigger, &mut run, status) {
                        error!("failed to run adapter or it failed to run CI: {e}");
+
                        let mut e = e.source();
+
                        while let Some(source) = e {
+
                            error!("caused by: {}", source);
+
                            e = source.source();
+
                        }
                    }

                    debug!("broker run {run:#?}");
@@ -239,6 +244,7 @@ mod test {
    #[test]
    fn executes_adapter() -> TestResult<()> {
        const ADAPTER: &str = r#"#!/bin/bash
+
read
echo '{"response":"triggered","run_id":{"id":"xyzzy"}}'
echo '{"response":"finished","result":"success"}'
"#;
@@ -270,6 +276,7 @@ echo '{"response":"finished","result":"success"}'
        log_in_tests();

        const ADAPTER: &str = r#"#!/bin/bash
+
read
echo '{"response":"triggered","run_id":{"id":"xyzzy"}}'
echo '{"response":"finished","result":"success"}'
echo woe be me 1>&2