diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-02-09 14:15:58 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-02-10 09:08:52 +0000 |
commit | 945f392392138bafcaa47a0486b627db7f4c4e97 (patch) | |
tree | 8526e93bbaff8625d187a4f4c28dd797a7b3c451 /AK | |
parent | 142f327e63f4bff804d689ca4973933792223e55 (diff) | |
download | serenity-945f392392138bafcaa47a0486b627db7f4c4e97.zip |
AK: Add an explicit Error factory to copy an existing error
As of now, there is a default copy constructor on Error. A future commit
will make this non-public to prevent implicit copies, so to prepare for
that, this adds a factory for the few cases where a copy is really
needed.
Diffstat (limited to 'AK')
-rw-r--r-- | AK/Error.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/AK/Error.h b/AK/Error.h index 0993f337df..4a04c69c80 100644 --- a/AK/Error.h +++ b/AK/Error.h @@ -25,6 +25,11 @@ public: [[nodiscard]] static Error from_syscall(StringView syscall_name, int rc) { return Error(syscall_name, rc); } [[nodiscard]] static Error from_string_view(StringView string_literal) { return Error(string_literal); } + [[nodiscard]] static Error copy(Error const& error) + { + return Error(error); + } + // NOTE: Prefer `from_string_literal` when directly typing out an error message: // // return Error::from_string_literal("Class: Some failure"); |