Error2.h#
Fully qualified name: carb/detail/Error2.h
File members: carb/detail/Error2.h
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
//
// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
// property and proprietary rights in and to this material, related
// documentation and any modifications thereto. Any use, reproduction,
// disclosure or distribution of this material and related documentation
// without an express license agreement from NVIDIA CORPORATION or
// its affiliates is strictly prohibited.
#pragma once
#ifndef carb_ErrorApi_latest
# error Must include via ../Error.h
#endif
#if !CARB_VERSION_ATLEAST(carb_ErrorApi, 2, 0)
# error Version too low to be included
#endif
#include "../IObject.h"
#include "../../omni/Expected.h"
namespace carb
{
#ifndef DOXYGEN_BUILD
inline namespace v2
{
#endif
class Error : public IObject
{
public:
virtual ErrorCode getCode() const noexcept = 0;
virtual cpp::zstring_view getMessage() const noexcept = 0;
virtual bool hasCustomMessage() const noexcept = 0;
};
using ErrorPtr = ObjectPtr<Error>;
class IError
{
public:
CARB_PLUGIN_INTERFACE_EX("carb::ErrorApi", carb_ErrorApi_latest, carb_ErrorApi)
virtual ErrorPtr viewCurrentError() const noexcept = 0;
virtual void setError(ErrorPtr error) const noexcept = 0;
virtual void setErrorOom() const noexcept = 0;
virtual omni::expected<void, ErrorCode> setError(ErrorCode code, cpp::string_view message = {}) const noexcept = 0;
virtual omni::expected<ErrorPtr, ErrorCode> errorCreate(ErrorCode code,
cpp::string_view message = {}) const noexcept = 0;
virtual cpp::optional<std::pair<cpp::zstring_view /*name*/, cpp::zstring_view /*message*/>> getCodeDescription(
ErrorCode code) const noexcept = 0;
virtual ErrorCode currentError(cpp::zstring_view* outMessage = nullptr) const noexcept = 0;
};
#ifndef DOXYGEN_BUILD
} // inline namespace v2
#endif
} // namespace carb