Skip to content

Commit

Permalink
GH-139 Reuse existing fleet validation error message creator
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed May 26, 2022
1 parent 0d4bee1 commit 9826ff9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 44 deletions.
23 changes: 1 addition & 22 deletions fleet1.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,28 +98,7 @@

if (!$fleetArrayParsingResult['isValid']) {
$firstValidationError = $fleetArrayParsingResult['errors'][0];

$errorMessage = null;
switch ($firstValidationError['errorCode']) {
case 'INVALID_SHIP_ID':
$errorMessage = $_Lang['fl1_BadShipGiven'];
break;
case 'SHIP_WITH_NO_ENGINE':
$errorMessage = $_Lang['fl1_CantSendUnflyable'];
break;
case 'INVALID_SHIP_COUNT':
$errorMessage = $_Lang['fleet_generic_errors_invalidshipcount'];
break;
case 'SHIP_COUNT_EXCEEDS_AVAILABLE':
$errorMessage = $_Lang['fl1_NoEnoughShips'];
break;
case 'NO_SHIPS':
$errorMessage = $_Lang['fl1_NoShipsGiven'];
break;
default:
$errorMessage = $_Lang['fleet_generic_errors_unknown'];
break;
}
$errorMessage = FlightControl\Utils\Errors\mapFleetArrayValidationErrorToReadableMessage($firstValidationError);

message($errorMessage, $ErrorTitle, 'fleet.php', 3);
}
Expand Down
23 changes: 1 addition & 22 deletions fleet2.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,28 +179,7 @@

if (!$fleetArrayParsingResult['isValid']) {
$firstValidationError = $fleetArrayParsingResult['errors'][0];

$errorMessage = null;
switch ($firstValidationError['errorCode']) {
case 'INVALID_SHIP_ID':
$errorMessage = $_Lang['fl1_BadShipGiven'];
break;
case 'SHIP_WITH_NO_ENGINE':
$errorMessage = $_Lang['fl1_CantSendUnflyable'];
break;
case 'INVALID_SHIP_COUNT':
$errorMessage = $_Lang['fleet_generic_errors_invalidshipcount'];
break;
case 'SHIP_COUNT_EXCEEDS_AVAILABLE':
$errorMessage = $_Lang['fl1_NoEnoughShips'];
break;
case 'NO_SHIPS':
$errorMessage = $_Lang['fl1_NoShipsGiven'];
break;
default:
$errorMessage = $_Lang['fleet_generic_errors_unknown'];
break;
}
$errorMessage = FlightControl\Utils\Errors\mapFleetArrayValidationErrorToReadableMessage($firstValidationError);

message($errorMessage, $ErrorTitle, 'fleet.php', 3);
}
Expand Down

0 comments on commit 9826ff9

Please sign in to comment.