* Error handler. Sets everything up to show an error message and to clean * up the mess of a partial savegame load. * @param string The translatable error message to show. * @param extra_msg An extra error message coming from one of the APIs. * @note This function does never return as it throws an exception to * break out of all the saveload code. */
| 337 | * break out of all the saveload code. |
| 338 | */ |
| 339 | [[noreturn]] void SlError(StringID string, const std::string &extra_msg) |
| 340 | { |
| 341 | /* Distinguish between loading into _load_check_data vs. normal save/load. */ |
| 342 | if (_sl.action == SLA_LOAD_CHECK) { |
| 343 | _load_check_data.error = string; |
| 344 | _load_check_data.error_msg = extra_msg; |
| 345 | } else { |
| 346 | _sl.error_str = string; |
| 347 | _sl.extra_msg = extra_msg; |
| 348 | } |
| 349 | |
| 350 | /* We have to nullptr all pointers here; we might be in a state where |
| 351 | * the pointers are actually filled with indices, which means that |
| 352 | * when we access them during cleaning the pool dereferences of |
| 353 | * those indices will be made with segmentation faults as result. */ |
| 354 | if (_sl.action == SLA_LOAD || _sl.action == SLA_PTRS) SlNullPointers(); |
| 355 | |
| 356 | /* Logging could be active. */ |
| 357 | _gamelog.StopAnyAction(); |
| 358 | |
| 359 | throw std::exception(); |
| 360 | } |
| 361 | |
| 362 | /** |
| 363 | * Error handler for corrupt savegames. Sets everything up to show the |
no test coverage detected