mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
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.
This commit is contained in:
parent
142f327e63
commit
945f392392
Notes:
sideshowbarker
2024-07-17 02:39:10 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/945f392392 Pull-request: https://github.com/SerenityOS/serenity/pull/17399 Reviewed-by: https://github.com/linusg
1 changed files with 5 additions and 0 deletions
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue