diff options
Diffstat (limited to 'dev/CompilerKit/ErrorOr.h')
| -rw-r--r-- | dev/CompilerKit/ErrorOr.h | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/dev/CompilerKit/ErrorOr.h b/dev/CompilerKit/ErrorOr.h index ef6cb84..d5a1c08 100644 --- a/dev/CompilerKit/ErrorOr.h +++ b/dev/CompilerKit/ErrorOr.h @@ -2,19 +2,20 @@ * ======================================================== * * CompilerKit - * Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved. + * Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under Apache 2.0. * * ======================================================== */ #pragma once +#include <CompilerKit/StringKit.h> #include <CompilerKit/Defines.h> #include <CompilerKit/ErrorID.h> #include <CompilerKit/Ref.h> namespace CompilerKit { -using ErrorT = UInt32; +using ErrorT = Int32; template <typename T> class ErrorOr final { @@ -23,18 +24,16 @@ class ErrorOr final { ~ErrorOr() = default; public: - explicit ErrorOr(Int32 err) : mId(err) {} - - explicit ErrorOr(nullPtr Null) {} - - explicit ErrorOr(T Class) : mRef(Class) {} + explicit ErrorOr(ErrorT err) : mId(err) {} + explicit ErrorOr(nullPtr null) {} + explicit ErrorOr(T klass) : mRef(klass) {} ErrorOr& operator=(const ErrorOr&) = default; ErrorOr(const ErrorOr&) = default; Ref<T> Leak() { return mRef; } - Int32 Error() { return mId; } + ErrorT Error() { return mId; } Bool HasError() { return mId != NECTI_SUCCESS; } @@ -42,9 +41,9 @@ class ErrorOr final { private: Ref<T> mRef; - Int32 mId{0}; + ErrorT mId{0}; }; -using ErrorOrAny = ErrorOr<voidPtr>; - +using ErrorOrAny = ErrorOr<VoidPtr>; +using ErrorOrString = ErrorOr<STLString>; } // namespace CompilerKit |
