# ai_error.hpp File Reference

Everything to query errors. More...

`#include "ai_object.hpp"`
`#include <map>`

Go to the source code of this file.

## Data Structures
class | AIError
| Class that handles all error related functions. More...
## Defines
#define | EnforcePrecondition(returnval, condition)
| Helper to write precondition enforcers for the AI API in an abbreviated manner.
#define | EnforcePreconditionCustomError(returnval, condition, error_code)
| Helper to write precondition enforcers for the AI API in an abbreviated manner.

## Detailed Description

Everything to query errors.

Definition in file ai_error.hpp.

## Define Documentation

#define EnforcePrecondition | ( | returnval,
|  | condition |  | ) |

Value:

    if (!(condition)) {                                           \
        AIObject::SetLastError(AIError::ERR_PRECONDITION_FAILED);   \
        return returnval;                                           \
      }

Helper to write precondition enforcers for the AI API in an abbreviated manner.

Parameters:

  | returnval | The value to return on failure.
  | condition | The condition that must be obeyed.

Definition at line 16 of file ai_error.hpp.

Referenced by AIRoad::_BuildRoadInternal(), AIRoad::_BuildRoadStationInternal(), AIVehicle::_MoveWagonInternal(), AIVehicle::_SellWagonInternal(), AIOrder::_SetOrderFlags(), AIOrder::AppendConditionalOrder(), AIOrder::AppendOrder(), AIAirport::BuildAirport(), AIBridge::BuildBridge(), AIMarine::BuildBuoy(), AIMarine::BuildCanal(), AICompany::BuildCompanyHQ(), AIMarine::BuildDock(), AIIndustryType::BuildIndustry(), AIMarine::BuildLock(), AIRail::BuildNewGRFRailStation(), AIRail::BuildRail(), AIRail::BuildRailDepot(), AIRail::BuildRailStation(), AIRail::BuildRailTrack(), AIRail::BuildRailWaypoint(), AIRoad::BuildRoadDepot(), AISign::BuildSign(), AIRail::BuildSignal(), AITunnel::BuildTunnel(), AIVehicle::BuildVehicle(), AIMarine::BuildWaterDepot(), AIVehicle::CloneVehicle(), AIRail::ConvertRailType(), AIOrder::CopyOrders(), AIGroup::DeleteGroup(), AITile::DemolishTile(), AIGroup::EnableAutoReplaceProtection(), AIOrder::InsertConditionalOrder(), AIOrder::InsertOrder(), AITile::LevelTiles(), AITile::LowerTile(), AIOrder::MoveOrder(), AIGroup::MoveVehicle(), AITown::PerformTownAction(), AITile::PlantTree(), AITile::PlantTreeRectangle(), AIIndustryType::ProspectIndustry(), AITile::RaiseTile(), AIVehicle::RefitVehicle(), AIAirport::RemoveAirport(), AIBridge::RemoveBridge(), AIMarine::RemoveBuoy(), AIMarine::RemoveCanal(), AIMarine::RemoveDock(), AIMarine::RemoveLock(), AIOrder::RemoveOrder(), AIRail::RemoveRail(), AIRail::RemoveRailStationTileRect(), AIRail::RemoveRailTrack(), AIRail::RemoveRailWaypoint(), AIRoad::RemoveRoad(), AIRoad::RemoveRoadDepot(), AIRoad::RemoveRoadFull(), AIRoad::RemoveRoadStation(), AISign::RemoveSign(), AIRail::RemoveSignal(), AITunnel::RemoveTunnel(), AIMarine::RemoveWaterDepot(), AIVehicle::ReverseVehicle(), AIVehicle::SellVehicle(), AIVehicle::SendVehicleToDepot(), AIGroup::SetAutoReplace(), AICompany::SetLoanAmount(), AICompany::SetMinimumLoanAmount(), AIWaypoint::SetName(), AIVehicle::SetName(), AIStation::SetName(), AISign::SetName(), AIGroup::SetName(), AICompany::SetName(), AIOrder::SetOrderCompareFunction(), AIOrder::SetOrderCompareValue(), AIOrder::SetOrderCondition(), AIOrder::SetOrderJumpTo(), AICompany::SetPresidentName(), AIOrder::ShareOrders(), AIOrder::SkipToOrder(), AIVehicle::SkipToVehicleOrder(), AIVehicle::StartStopVehicle(), AIGroup::StopAutoReplace(), and AIOrder::UnshareOrders().

#define EnforcePreconditionCustomError | ( | returnval,
|  | condition,
|  | error_code |  | ) |

Value:

    if (!(condition)) {                                                      \
        AIObject::SetLastError(error_code);                                    \
        return returnval;                                                      \
      }

Helper to write precondition enforcers for the AI API in an abbreviated manner.

Parameters:

  | returnval | The value to return on failure.
  | condition | The condition that must be obeyed.
  | error_code | The error code passed to AIObject::SetLastError.

Definition at line 28 of file ai_error.hpp.

Referenced by AISign::BuildSign(), AIVehicle::BuildVehicle(), AIWaypoint::SetName(), AIVehicle::SetName(), AIStation::SetName(), AISign::SetName(), AIGroup::SetName(), and AICompany::SetName().