1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:27:35 +00:00

Chess: Slightly improve error propagation during startup

This commit is contained in:
Ben Wiederhake 2023-05-07 01:59:10 +02:00 committed by Jelle Raaijmakers
parent 0fe29a48ad
commit 449911c286
4 changed files with 14 additions and 15 deletions

View file

@ -12,8 +12,15 @@
#include <LibChess/UCIEndpoint.h>
class ChessEngine : public Chess::UCI::Endpoint {
C_OBJECT(ChessEngine)
C_OBJECT_ABSTRACT(ChessEngine)
public:
static ErrorOr<NonnullRefPtr<ChessEngine>> try_create(NonnullOwnPtr<Core::File> in, NonnullOwnPtr<Core::File> out)
{
auto engine = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ChessEngine()));
TRY(engine->set_in(move(in)));
engine->set_out(move(out));
return engine;
}
virtual ~ChessEngine() override = default;
virtual void handle_uci() override;
@ -26,8 +33,8 @@ public:
Function<void(int)> on_quit;
private:
ChessEngine(NonnullOwnPtr<Core::File> in, NonnullOwnPtr<Core::File> out)
: Endpoint(move(in), move(out))
ChessEngine()
: Endpoint()
{
on_command_read_error = [](auto command, auto error) {
outln("{}: '{}'", error, command);