nu_protocol/errors/shell_error/
job.rs

1use miette::Diagnostic;
2use thiserror::Error;
3
4use crate::{JobId, Span};
5
6/// Errors when working working with jobs.
7#[derive(Debug, Clone, Copy, PartialEq, Error, Diagnostic)]
8pub enum JobError {
9    #[error("Job {id} not found")]
10    #[diagnostic(
11        code(nu::shell::job::not_found),
12        help(
13            "The operation could not be completed, there is no job currently running with this id"
14        )
15    )]
16    NotFound { span: Span, id: JobId },
17
18    #[error("No frozen job to unfreeze")]
19    #[diagnostic(
20        code(nu::shell::job::none_to_unfreeze),
21        help("There is currently no frozen job to unfreeze")
22    )]
23    NoneToUnfreeze { span: Span },
24
25    #[error("Job {id} is not frozen")]
26    #[diagnostic(
27        code(nu::shell::job::cannot_unfreeze),
28        help("You tried to unfreeze a job which is not frozen")
29    )]
30    CannotUnfreeze { span: Span, id: JobId },
31
32    #[error("The job {id} is frozen")]
33    #[diagnostic(
34        code(nu::shell::job::already_frozen),
35        help("This operation cannot be performed because the job is frozen")
36    )]
37    AlreadyFrozen { span: Span, id: JobId },
38
39    #[error("No message was received in the requested time interval")]
40    #[diagnostic(
41        code(nu::shell::job::recv_timeout),
42        help("No message arrived within the specified time limit")
43    )]
44    RecvTimeout { span: Span },
45}