#ifndef PROCESS_LIBPROCESS_INCLUDE_PROCESS_EXCEPTIONS_HPP #define PROCESS_LIBPROCESS_INCLUDE_PROCESS_EXCEPTIONS_HPP #include namespace process { /** Base class for all libprocess exceptions */ class ProcessException : public std::runtime_error { public: explicit ProcessException(const std::basic_string& what) noexcept : std::runtime_error(what) { } ~ProcessException() override = default; ProcessException(ProcessException const&) = delete; ProcessException& operator=(ProcessException const&) & = delete; ProcessException(ProcessException&&) = delete; ProcessException& operator=(ProcessException&&) & = delete; }; /** Thrown if something goes wrong during process creation */ class ProcessCreationException : public ProcessException { public: using ProcessException::ProcessException; ~ProcessCreationException() override = default; ProcessCreationException(ProcessCreationException const&) = delete; ProcessCreationException& operator=(ProcessCreationException const&) & = delete; ProcessCreationException(ProcessCreationException&&) = delete; ProcessCreationException& operator=(ProcessCreationException&&) & = delete; }; /** Thrown if something goes wrong while attempting to start a process */ class ProcessStartException : public ProcessException { public: using ProcessException::ProcessException; ~ProcessStartException() override = default; ProcessStartException(ProcessStartException const&) = delete; ProcessStartException& operator=(ProcessStartException const&) & = delete; ProcessStartException(ProcessStartException&&) = delete; ProcessStartException& operator=(ProcessStartException&&) & = delete; }; /** Thrown if something goes wrong while attempting to stop a process */ class ProcessStopException : public ProcessException { public: using ProcessException::ProcessException; ~ProcessStopException() override = default; ProcessStopException(ProcessStopException const&) = delete; ProcessStopException& operator=(ProcessStopException const&) & = delete; ProcessStopException(ProcessStopException&&) = delete; ProcessStopException& operator=(ProcessStopException&&) & = delete; }; /** Thrown if Process::start() is called but the process is already running */ class ProcessAlreadyStartedException : public ProcessException { public: using ProcessException::ProcessException; ~ProcessAlreadyStartedException() override = default; ProcessAlreadyStartedException(ProcessAlreadyStartedException const&) = delete; ProcessAlreadyStartedException& operator=(ProcessAlreadyStartedException const&) & = delete; ProcessAlreadyStartedException(ProcessAlreadyStartedException&&) = delete; ProcessAlreadyStartedException& operator=(ProcessAlreadyStartedException&&) & = delete; }; /** Thrown if Process::stop() is called but the process is already stopped */ class ProcessAlreadyStoppedException : public ProcessException { public: using ProcessException::ProcessException; ~ProcessAlreadyStoppedException() override = default; ProcessAlreadyStoppedException(ProcessAlreadyStoppedException const&) = delete; ProcessAlreadyStoppedException& operator=(ProcessAlreadyStoppedException const&) & = delete; ProcessAlreadyStoppedException(ProcessAlreadyStoppedException&&) = delete; ProcessAlreadyStoppedException& operator=(ProcessAlreadyStoppedException&&) & = delete; }; /** Thrown if the state of a process cannot be updated */ class ProcessUpdateException : public ProcessException { public: using ProcessException::ProcessException; ~ProcessUpdateException() override = default; ProcessUpdateException(ProcessUpdateException const&) = delete; ProcessUpdateException& operator=(ProcessUpdateException const&) & = delete; ProcessUpdateException(ProcessUpdateException&&) = delete; ProcessUpdateException& operator=(ProcessUpdateException&&) & = delete; }; /** Thrown if the termination of a process fails */ class ProcessTerminationException : public ProcessException { public: using ProcessException::ProcessException; ~ProcessTerminationException() override = default; ProcessTerminationException(ProcessTerminationException const&) = delete; ProcessTerminationException& operator=(ProcessTerminationException const&) & = delete; ProcessTerminationException(ProcessTerminationException&&) = delete; ProcessTerminationException& operator=(ProcessTerminationException&&) & = delete; }; } #endif