mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-08-17 01:10:28 +03:00
AK: Mark Error::from_ functions as [[nodiscard]]
Prevents mistakes like the one fixed in #16672.
This commit is contained in:
parent
c96e663b0a
commit
8932b28b8a
Notes:
sideshowbarker
2024-07-17 02:59:43 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/8932b28b8a Pull-request: https://github.com/SerenityOS/serenity/pull/16673 Reviewed-by: https://github.com/trflynn89 ✅
@ -21,9 +21,9 @@ namespace AK {
|
||||
|
||||
class Error {
|
||||
public:
|
||||
static Error from_errno(int code) { return Error(code); }
|
||||
static Error from_syscall(StringView syscall_name, int rc) { return Error(syscall_name, rc); }
|
||||
static Error from_string_view(StringView string_literal) { return Error(string_literal); }
|
||||
[[nodiscard]] static Error from_errno(int code) { return Error(code); }
|
||||
[[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); }
|
||||
|
||||
// NOTE: Prefer `from_string_literal` when directly typing out an error message:
|
||||
//
|
||||
@ -32,7 +32,7 @@ public:
|
||||
// If you need to return a static string based on a dynamic condition (like
|
||||
// picking an error from an array), then prefer `from_string_view` instead.
|
||||
template<size_t N>
|
||||
ALWAYS_INLINE static Error from_string_literal(char const (&string_literal)[N])
|
||||
[[nodiscard]] ALWAYS_INLINE static Error from_string_literal(char const (&string_literal)[N])
|
||||
{
|
||||
return from_string_view(StringView { string_literal, N - 1 });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user