temporal_sdk_core/
errors.rs1use crate::{
2 protos::coresdk::activity_result::ActivityResult,
3 protos::coresdk::workflow_completion::WfActivationCompletion,
4 protos::temporal::api::workflowservice::v1::PollWorkflowTaskQueueResponse,
5 workflow::WorkflowError,
6};
7use tonic::codegen::http::uri::InvalidUri;
8
9pub(crate) struct ShutdownErr;
10pub(crate) struct WorkflowUpdateError {
11 pub source: WorkflowError,
13 pub run_id: String,
15}
16
17#[derive(thiserror::Error, Debug)]
19pub enum CoreInitError {
20 #[error("Invalid URI: {0:?}")]
22 InvalidUri(#[from] InvalidUri),
23 #[error("Server connection error: {0:?}")]
25 TonicTransportError(#[from] tonic::transport::Error),
26}
27
28#[derive(thiserror::Error, Debug)]
30pub enum PollWfError {
31 #[error("There was an error with the workflow instance with run id ({run_id}): {source:?}")]
34 WorkflowUpdateError {
35 source: WorkflowError,
37 run_id: String,
39 },
40 #[error("Poll workflow response from server was malformed: {0:?}")]
43 BadPollResponseFromServer(PollWorkflowTaskQueueResponse),
44 #[error("Core is shut down and there are no more workflow replay tasks")]
48 ShutDown,
49 #[error("Unhandled error when calling the temporal server: {0:?}")]
52 TonicError(#[from] tonic::Status),
53}
54
55impl From<WorkflowUpdateError> for PollWfError {
56 fn from(e: WorkflowUpdateError) -> Self {
57 Self::WorkflowUpdateError {
58 source: e.source,
59 run_id: e.run_id,
60 }
61 }
62}
63
64impl From<ShutdownErr> for PollWfError {
65 fn from(_: ShutdownErr) -> Self {
66 Self::ShutDown
67 }
68}
69
70#[derive(thiserror::Error, Debug)]
72pub enum PollActivityError {
73 #[error("Core is shut down")]
76 ShutDown,
77 #[error("Unhandled error when calling the temporal server: {0:?}")]
80 TonicError(#[from] tonic::Status),
81}
82
83impl From<ShutdownErr> for PollActivityError {
84 fn from(_: ShutdownErr) -> Self {
85 Self::ShutDown
86 }
87}
88
89#[derive(thiserror::Error, Debug)]
91#[allow(clippy::large_enum_variant)]
92pub enum CompleteWfError {
93 #[error("Lang SDK sent us a malformed workflow completion ({reason}): {completion:?}")]
95 MalformedWorkflowCompletion {
96 reason: String,
98 completion: Option<WfActivationCompletion>,
100 },
101 #[error("There was an error with the workflow instance with run id ({run_id}): {source:?}")]
104 WorkflowUpdateError {
105 source: WorkflowError,
107 run_id: String,
109 },
110 #[error("Unhandled command when completing workflow activation")]
114 UnhandledCommandWhenCompleting,
115 #[error("Unhandled error when calling the temporal server: {0:?}")]
118 TonicError(#[from] tonic::Status),
119}
120
121impl From<WorkflowUpdateError> for CompleteWfError {
122 fn from(e: WorkflowUpdateError) -> Self {
123 Self::WorkflowUpdateError {
124 source: e.source,
125 run_id: e.run_id,
126 }
127 }
128}
129
130#[derive(thiserror::Error, Debug)]
132pub enum CompleteActivityError {
133 #[error("Lang SDK sent us a malformed activity completion ({reason}): {completion:?}")]
135 MalformedActivityCompletion {
136 reason: String,
138 completion: Option<ActivityResult>,
140 },
141 #[error("Unhandled error when calling the temporal server: {0:?}")]
144 TonicError(#[from] tonic::Status),
145}
146
147#[derive(thiserror::Error, Debug)]
149pub enum ActivityHeartbeatError {
150 #[error("Heartbeat request must contain heartbeat timeout.")]
151 HeartbeatTimeoutNotSet,
152 #[error("Heartbeat request must contain valid heartbeat timeout.")]
153 InvalidHeartbeatTimeout,
154 #[error("New heartbeat requests are not accepted while shutting down")]
155 ShuttingDown,
156 #[error("Unable to dispatch heartbeat.")]
157 SendError,
158}