Skip to content

Commit

Permalink
add az exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-toterman committed Feb 6, 2025
1 parent 96d78f4 commit d5a16ab
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions include/multipass/exceptions/availability_zone_exceptions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (C) Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

#ifndef MULTIPASS_AVAILABILITY_ZONE_EXCEPTIONS_H
#define MULTIPASS_AVAILABILITY_ZONE_EXCEPTIONS_H

#include <stdexcept>
#include <string>

#include <multipass/format.h>

namespace multipass
{
struct AvailabilityZoneError : std::runtime_error
{
template <typename... Args>
explicit AvailabilityZoneError(const char* fmt, Args&&... args)
: runtime_error(fmt::format(fmt, std::forward<Args>(args)...))
{
}
};

struct AvailabilityZoneSerializationError final : AvailabilityZoneError
{
using AvailabilityZoneError::AvailabilityZoneError;
};

struct AvailabilityZoneDeserializationError final : AvailabilityZoneError
{
using AvailabilityZoneError::AvailabilityZoneError;
};

struct AvailabilityZoneManagerError : std::runtime_error
{
template <typename... Args>
explicit AvailabilityZoneManagerError(const char* fmt, Args&&... args)
: runtime_error(fmt::format(fmt, std::forward<Args>(args)...))
{
}
};

struct AvailabilityZoneManagerSerializationError final : AvailabilityZoneManagerError
{
using AvailabilityZoneManagerError::AvailabilityZoneManagerError;
};

struct AvailabilityZoneManagerDeserializationError final : AvailabilityZoneManagerError
{
using AvailabilityZoneManagerError::AvailabilityZoneManagerError;
};

struct AvailabilityZoneNotFound final : AvailabilityZoneManagerError {
explicit AvailabilityZoneNotFound(const std::string& name) : AvailabilityZoneManagerError{"no AZ with name {:?} found", name} {}
};

struct NoAvailabilityZoneAvailable final : AvailabilityZoneManagerError {
NoAvailabilityZoneAvailable() : AvailabilityZoneManagerError{"no AZ is available"} {}
};
} // namespace multipass

#endif // MULTIPASS_AVAILABILITY_ZONE_EXCEPTIONS_H

0 comments on commit d5a16ab

Please sign in to comment.