AXIAM C++ SDK 1.0.0-alpha8
Authentication, authorization, JWKS & route guards (REST + mTLS)
Loading...
Searching...
No Matches
errors.hpp
Go to the documentation of this file.
1// §2 Error taxonomy — exactly three top-level error types, exposed as an
2// exception hierarchy rooted at AxiamError.
3#pragma once
4
5#include <optional>
6#include <stdexcept>
7#include <string>
8
9namespace axiam {
10
12class AxiamError : public std::runtime_error {
13public:
14 explicit AxiamError(const std::string& message) : std::runtime_error(message) {}
15};
16
19class AuthError : public AxiamError {
20public:
21 explicit AuthError(const std::string& message) : AxiamError(message) {}
22};
23
26class AuthzError : public AxiamError {
27public:
28 explicit AuthzError(const std::string& message) : AxiamError(message) {}
29
30 AuthzError(const std::string& message, std::optional<std::string> action,
31 std::optional<std::string> resource_id)
32 : AxiamError(message),
33 action_(std::move(action)),
34 resource_id_(std::move(resource_id)) {}
35
36 const std::optional<std::string>& action() const noexcept { return action_; }
37 const std::optional<std::string>& resource_id() const noexcept { return resource_id_; }
38
39private:
40 std::optional<std::string> action_;
41 std::optional<std::string> resource_id_;
42};
43
47class NetworkError : public AxiamError {
48public:
49 explicit NetworkError(const std::string& message)
50 : AxiamError(message), cause_(message) {}
51
52 NetworkError(const std::string& message, std::string cause)
53 : AxiamError(message), cause_(std::move(cause)) {}
54
56 const std::string& cause() const noexcept { return cause_; }
57
58private:
59 std::string cause_;
60};
61
62} // namespace axiam
Authentication failure: wrong credentials, expired session, MFA failure, or a 401 on the refresh call...
Definition errors.hpp:19
AuthError(const std::string &message)
Definition errors.hpp:21
Authorization failure: authenticated but not permitted.
Definition errors.hpp:26
AuthzError(const std::string &message)
Definition errors.hpp:28
const std::optional< std::string > & resource_id() const noexcept
Definition errors.hpp:37
AuthzError(const std::string &message, std::optional< std::string > action, std::optional< std::string > resource_id)
Definition errors.hpp:30
const std::optional< std::string > & action() const noexcept
Definition errors.hpp:36
Base class for every error the SDK raises. Never carries raw token material.
Definition errors.hpp:12
AxiamError(const std::string &message)
Definition errors.hpp:14
Transport-level failure: connection refused, timeout, TLS error, DNS failure, malformed request (400)...
Definition errors.hpp:47
const std::string & cause() const noexcept
The underlying OS / transport error that triggered this failure.
Definition errors.hpp:56
NetworkError(const std::string &message, std::string cause)
Definition errors.hpp:52
NetworkError(const std::string &message)
Definition errors.hpp:49
Definition authenticator.hpp:40