mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-08-04 14:53:25 +02:00
Add thiserror instead of exposing eyre anonymous errors
The change here is to make it easier for the consumer to debug the api. Such that they can `match` on individual errors instead of having to parse text. eyre is convenient, but mostly from a consumers perspective
This commit is contained in:
@@ -5,20 +5,24 @@ use dagger_core::graphql_client::DefaultGraphQLClient;
|
||||
use dagger_core::config::Config;
|
||||
use dagger_core::engine::Engine as DaggerEngine;
|
||||
|
||||
use crate::errors::ConnectError;
|
||||
use crate::gen::Query;
|
||||
use crate::logging::StdLogger;
|
||||
use crate::querybuilder::query;
|
||||
|
||||
pub type DaggerConn = Arc<Query>;
|
||||
|
||||
pub async fn connect() -> eyre::Result<DaggerConn> {
|
||||
pub async fn connect() -> Result<DaggerConn, ConnectError> {
|
||||
let cfg = Config::new(None, None, None, None, Some(Arc::new(StdLogger::default())));
|
||||
|
||||
connect_opts(cfg).await
|
||||
}
|
||||
|
||||
pub async fn connect_opts(cfg: Config) -> eyre::Result<DaggerConn> {
|
||||
let (conn, proc) = DaggerEngine::new().start(&cfg).await?;
|
||||
pub async fn connect_opts(cfg: Config) -> Result<DaggerConn, ConnectError> {
|
||||
let (conn, proc) = DaggerEngine::new()
|
||||
.start(&cfg)
|
||||
.await
|
||||
.map_err(ConnectError::FailedToConnect)?;
|
||||
|
||||
Ok(Arc::new(Query {
|
||||
proc: proc.map(|p| Arc::new(p)),
|
||||
|
Reference in New Issue
Block a user