libdd_capabilities/spawn.rs
1// Copyright 2026-Present Datadog, Inc. https://www.datadoghq.com/
2// SPDX-License-Identifier: Apache-2.0
3
4//! Spawn-related types shared across platforms.
5//!
6//! Task spawning is handled internally by `SharedRuntime`; this module only
7//! provides the executor-agnostic [`SpawnError`] type used in join handles.
8
9use core::fmt;
10
11/// Executor-agnostic error returned when a spawned task is aborted or panics.
12#[derive(Debug)]
13pub struct SpawnError {
14 msg: String,
15}
16
17impl SpawnError {
18 pub fn new(msg: impl Into<String>) -> Self {
19 Self { msg: msg.into() }
20 }
21}
22
23impl fmt::Display for SpawnError {
24 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25 write!(f, "spawned task failed: {}", self.msg)
26 }
27}
28
29impl core::error::Error for SpawnError {}