Skip to content

Commit

Permalink
Store the original map filename in user error data
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSpen210 committed Dec 17, 2024
1 parent f4163c1 commit e760dbd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/user_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ class BarrierHole(TypedDict):
class ErrorInfo:
"""Data to display to the user."""
message: TransToken

# Map name, allowing error server to dump this for the user to report with.
vmf_fname_orig: str | None = None
vmf_fname_new: str | None = None

# Language file to use to translate things.
language_file: Path | None = None
# Logging context
context: str = ''
Expand Down
15 changes: 11 additions & 4 deletions src/vbsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
import logging
import pickle

import async_util

from aioresult import ResultCapture
from srctools import AtomicWriter, Keyvalues, Vec, FrozenVec, Angle
from srctools.dmx import Element
from srctools.vmf import VMF, Entity, Output
from srctools.game import Game
from srctools.vmf import VMF, Entity, Output
import async_util
import attrs
import srctools
import srctools.run
import srctools.logger
import srctools.run
import trio

from BEE2_config import ConfigFile
Expand Down Expand Up @@ -1717,12 +1719,17 @@ async def main(argv: list[str]) -> None:
raise
LOGGER.error('"User" error detected, aborting compile: ', exc_info=True)

error.info = attrs.evolve(error.info, vmf_fname_orig=path)

# Try to preserve the current map.
if vmf is not None:
error_fname = new_path[:-4] + '.error.vmf'
try:
save(vmf, new_path[:-4] + '.error.vmf') # noqa
save(vmf, error_fname) # noqa
except Exception:
pass
else:
error.info = attrs.evolve(error.info, vmf_fname_new=error_fname)

vmf = errors.make_map(error)

Expand Down

0 comments on commit e760dbd

Please sign in to comment.