mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 05:47:34 +00:00
AK: Convert AK::Format formatting helpers to returning ErrorOr<void>
This isn't a complete conversion to ErrorOr<void>, but a good chunk. The end goal here is to propagate buffer allocation failures to the caller, and allow the use of TRY() with formatting functions.
This commit is contained in:
parent
008355c222
commit
216e21a1fa
87 changed files with 450 additions and 448 deletions
|
@ -85,15 +85,15 @@ namespace AK {
|
|||
|
||||
template<>
|
||||
struct Formatter<Core::FileWatcherEvent> : Formatter<FormatString> {
|
||||
void format(FormatBuilder& builder, const Core::FileWatcherEvent& value)
|
||||
ErrorOr<void> format(FormatBuilder& builder, Core::FileWatcherEvent const& value)
|
||||
{
|
||||
Formatter<FormatString>::format(builder, "FileWatcherEvent(\"{}\", {})", value.event_path, value.type);
|
||||
return Formatter<FormatString>::format(builder, "FileWatcherEvent(\"{}\", {})", value.event_path, value.type);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Formatter<Core::FileWatcherEvent::Type> : Formatter<FormatString> {
|
||||
void format(FormatBuilder& builder, const Core::FileWatcherEvent::Type& value)
|
||||
ErrorOr<void> format(FormatBuilder& builder, Core::FileWatcherEvent::Type const& value)
|
||||
{
|
||||
char const* type;
|
||||
switch (value) {
|
||||
|
@ -116,7 +116,7 @@ struct Formatter<Core::FileWatcherEvent::Type> : Formatter<FormatString> {
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
builder.put_string(type);
|
||||
return builder.put_string(type);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ private:
|
|||
|
||||
template<>
|
||||
struct AK::Formatter<Core::Object> : AK::Formatter<FormatString> {
|
||||
void format(FormatBuilder& builder, const Core::Object& value)
|
||||
ErrorOr<void> format(FormatBuilder& builder, const Core::Object& value)
|
||||
{
|
||||
return AK::Formatter<FormatString>::format(builder, "{}({})", value.class_name(), &value);
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ private:
|
|||
|
||||
template<>
|
||||
struct AK::Formatter<Core::SocketAddress> : Formatter<String> {
|
||||
void format(FormatBuilder& builder, const Core::SocketAddress& value)
|
||||
ErrorOr<void> format(FormatBuilder& builder, Core::SocketAddress const& value)
|
||||
{
|
||||
return Formatter<String>::format(builder, value.to_string());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue