From 7bb12a4b833f0cc084af2c3707b1aebf85cbd533 Mon Sep 17 00:00:00 2001 From: Ashok Menon Date: Tue, 9 Jul 2024 13:05:59 +0100 Subject: [PATCH] fixup: clever errors --- examples/tic-tac-toe/move/sources/owned.move | 25 +++++++++------- examples/tic-tac-toe/move/sources/shared.move | 30 +++++++++++-------- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/examples/tic-tac-toe/move/sources/owned.move b/examples/tic-tac-toe/move/sources/owned.move index 6562b16aa86f0..18e0ecbcd3ebb 100644 --- a/examples/tic-tac-toe/move/sources/owned.move +++ b/examples/tic-tac-toe/move/sources/owned.move @@ -101,20 +101,25 @@ module tic_tac_toe::owned { // === Errors === - /// Move was for a position that doesn't exist on the board. - const EInvalidLocation: u64 = 0; + #[error] + const EInvalidLocation: vector = + b"Move was for a position that doesn't exist on the board"; - /// Game expected a move from another player. - const EWrongPlayer: u64 = 1; + #[error] + const EWrongPlayer: vector = + b"Game expected a move from another player"; - /// Game has not reached an end condition. - const ENotFinished: u64 = 2; + #[error] + const ENotFinished: vector = + b"Game has not reached an end condition"; - /// Can't place a mark on a finished game. - const EAlreadyFinished: u64 = 3; + #[error] + const EAlreadyFinished: vector = + b"Can't place a mark on a finished game"; - /// Game reached an end state that wasn't expected. - const EInvalidEndState: u64 = 4; + #[error] + const EInvalidEndState: vector = + b"Game reached an end state that wasn't expected"; // === Public Functions === diff --git a/examples/tic-tac-toe/move/sources/shared.move b/examples/tic-tac-toe/move/sources/shared.move index 94edcb9cd6bc6..5e3ffa7e0c22d 100644 --- a/examples/tic-tac-toe/move/sources/shared.move +++ b/examples/tic-tac-toe/move/sources/shared.move @@ -61,23 +61,29 @@ module tic_tac_toe::shared { // === Errors === - /// Move was for a position that doesn't exist on the board. - const EInvalidLocation: u64 = 0; + #[error] + const EInvalidLocation: vector = + b"Move was for a position that doesn't exist on the board."; - /// Game expected a move from another player. - const EWrongPlayer: u64 = 1; + #[error] + const EWrongPlayer: vector = + b"Game expected a move from another player"; - /// Attempt to place mark on a filled slot. - const EAlreadyFilled: u64 = 2; + #[error] + const EAlreadyFilled: vector = + b"Attempted to place a mark on a filled slot."; - /// Game has not reached an end condition. - const ENotFinished: u64 = 3; + #[error] + const ENotFinished: vector = + b"Game has not reached an end condition."; - /// Can't place a mark on a finished game. - const EAlreadyFinished: u64 = 4; + #[error] + const EAlreadyFinished: vector = + b"Can't place a mark on a finished game."; - /// Game reached an end state that wasn't expected. - const EInvalidEndState: u64 = 5; + #[error] + const EInvalidEndState: vector = + b"Game reached an end state that wasn't expected."; // === Public Functions ===