mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05: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
1 changed files with 4 additions and 4 deletions
|
@ -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…
Add table
Reference in a new issue