1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:57:45 +00:00

AK: Allow explicitly copying Errors in the Kernel

This commit is contained in:
Tim Schumacher 2023-02-10 11:40:12 +01:00 committed by Andreas Kling
parent cc8874b5aa
commit be25602d44

View file

@ -38,12 +38,14 @@ public:
return Error(syscall_name, rc); return Error(syscall_name, rc);
} }
[[nodiscard]] static Error from_string_view(StringView string_literal) { return Error(string_literal); } [[nodiscard]] static Error from_string_view(StringView string_literal) { return Error(string_literal); }
#endif
[[nodiscard]] static Error copy(Error const& error) [[nodiscard]] static Error copy(Error const& error)
{ {
return Error(error); return Error(error);
} }
#ifndef KERNEL
// NOTE: Prefer `from_string_literal` when directly typing out an error message: // NOTE: Prefer `from_string_literal` when directly typing out an error message:
// //
// return Error::from_string_literal("Class: Some failure"); // return Error::from_string_literal("Class: Some failure");
@ -108,10 +110,12 @@ private:
, m_syscall(true) , m_syscall(true)
{ {
} }
#endif
Error(Error const&) = default; Error(Error const&) = default;
Error& operator=(Error const&) = default; Error& operator=(Error const&) = default;
#ifndef KERNEL
StringView m_string_literal; StringView m_string_literal;
#endif #endif