qubit_task/service/task_execution_service_error.rs
1/*******************************************************************************
2 *
3 * Copyright (c) 2025 - 2026 Haixing Hu.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Licensed under the Apache License, Version 2.0.
8 *
9 ******************************************************************************/
10use thiserror::Error;
11
12use qubit_executor::service::SubmissionError;
13
14use super::task_id::TaskId;
15
16/// Error returned when [`TaskExecutionService`](super::TaskExecutionService)
17/// cannot accept a task.
18///
19/// This error is about the service submission path. The accepted task's own
20/// result is still reported through [`TaskHandle`](qubit_executor::TaskHandle).
21///
22#[derive(Debug, Error)]
23pub enum TaskExecutionServiceError {
24 /// Another retained task record already uses the same task ID.
25 #[error("task {0} already exists")]
26 DuplicateTask(TaskId),
27
28 /// The service is suspended and temporarily refuses new tasks.
29 #[error("task execution service is suspended")]
30 Suspended,
31
32 /// The underlying thread pool rejected the task.
33 #[error(transparent)]
34 Rejected(#[from] SubmissionError),
35}