diff options
author | Tim Ledbetter <timledbetter@gmail.com> | 2023-04-30 17:05:11 +0100 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2023-05-03 08:31:34 +0100 |
commit | 56dde3df54ae3b2f6fa186e583e13605a668064a (patch) | |
tree | bb31ae0216e6591ec04ae4d49c3acdbfd9addf88 /Userland/Services | |
parent | 25778d07e986b512aaa87a622cd6efb918b342dc (diff) | |
download | serenity-56dde3df54ae3b2f6fa186e583e13605a668064a.zip |
LibChess+ChessEngine: Don't crash on error when reading UCI commands
ChessEngine and the chess GUI will no longer crash on error while
reading UCI commands. ChessEngine will print a message to the standard
output, while the GUI will ignore unknown commands. Both will print
the error to the debug log if the UCI_DEBUG flag is enabled.
Trailing and preceding whitespace is now stripped from commands before
they are parsed. Commands which are just whitespace no longer produce
errors.
Diffstat (limited to 'Userland/Services')
-rw-r--r-- | Userland/Services/ChessEngine/ChessEngine.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Userland/Services/ChessEngine/ChessEngine.h b/Userland/Services/ChessEngine/ChessEngine.h index 9afc0fc394..5422878843 100644 --- a/Userland/Services/ChessEngine/ChessEngine.h +++ b/Userland/Services/ChessEngine/ChessEngine.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, the SerenityOS developers. + * Copyright (c) 2023, Tim Ledbetter <timledbetter@gmail.com> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -25,10 +26,12 @@ public: Function<void(int)> on_quit; private: - ChessEngine() = default; ChessEngine(NonnullRefPtr<Core::IODevice> in, NonnullRefPtr<Core::IODevice> out) : Endpoint(in, out) { + on_command_read_error = [](auto command, auto error) { + outln("{}: '{}'", error, command); + }; } Chess::Board m_board; |