Skip to main content

stepflow_client/
error.rs

1// Copyright 2025 DataStax Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4// in compliance with the License. You may obtain a copy of the License at
5//
6//     http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software distributed under the License
9// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10// or implied. See the License for the specific language governing permissions and limitations under
11// the License.
12
13/// Errors returned by [`crate::StepflowClient`] operations.
14#[derive(thiserror::Error, Debug)]
15pub enum ClientError {
16    #[error("Failed to connect to orchestrator at {url}: {source}")]
17    Connection {
18        url: String,
19        #[source]
20        source: Box<dyn std::error::Error + Send + Sync>,
21    },
22    #[error("gRPC error: {0}")]
23    Grpc(#[from] tonic::Status),
24    #[error("Serialization error: {0}")]
25    Serialization(#[from] serde_json::Error),
26    #[error("Invalid response: {0}")]
27    InvalidResponse(String),
28    #[error("Local orchestrator error: {0}")]
29    LocalServer(String),
30}
31
32/// Errors returned by [`crate::FlowBuilder`].
33#[derive(thiserror::Error, Debug)]
34pub enum BuilderError {
35    #[error("Output expression not set — call .output() before .build()")]
36    OutputNotSet,
37    #[error("Duplicate step ID: {0}")]
38    DuplicateStep(String),
39}
40
41pub type ClientResult<T> = Result<T, ClientError>;
42pub type BuilderResult<T> = Result<T, BuilderError>;