WebHost: report back generation errors to user
This commit is contained in:
parent
38490813de
commit
e005fb52f7
|
@ -142,12 +142,13 @@ def gen_game(gen_options, race=False, owner=None, sid=None):
|
|||
ERmain(erargs, seed)
|
||||
|
||||
return upload_to_db(target.name, owner, sid, race)
|
||||
except BaseException:
|
||||
except BaseException as e:
|
||||
if sid:
|
||||
with db_session:
|
||||
gen = Generation.get(id=sid)
|
||||
if gen is not None:
|
||||
gen.state = STATE_ERROR
|
||||
gen.meta = (e.__class__.__name__ + ": "+ str(e)).encode()
|
||||
raise
|
||||
|
||||
|
||||
|
@ -162,7 +163,8 @@ def wait_seed(seed: UUID):
|
|||
if not generation:
|
||||
return "Generation not found."
|
||||
elif generation.state == STATE_ERROR:
|
||||
return "Generation failed, please retry."
|
||||
import html
|
||||
return f"Generation failed, please retry. <br> {html.escape(generation.meta.decode())}"
|
||||
return render_template("wait_seed.html", seed_id=seed_id)
|
||||
|
||||
|
||||
|
|
|
@ -50,5 +50,5 @@ class Generation(db.Entity):
|
|||
id = PrimaryKey(UUID, default=uuid4)
|
||||
owner = Required(UUID)
|
||||
options = Required(bytes, lazy=True) # these didn't work as JSON on mariaDB, so they're getting pickled now
|
||||
meta = Required(bytes, lazy=True)
|
||||
meta = Required(bytes, lazy=True) # if state is -1 (error) this will contain an utf-8 encoded error message
|
||||
state = Required(int, default=0, index=True)
|
||||
|
|
Loading…
Reference in New Issue