WebHost: Improve user friendliness of generation failure webpage (#4964)
* Improve user friendliness of generation failure webpage. * Add details to other render for seedError.html. * Refactor css to avoid !important tags. * Update WebHostLib/static/styles/themes/ocean-island.css Co-authored-by: qwint <qwint.42@gmail.com> * Update WebHostLib/generate.py Co-authored-by: qwint <qwint.42@gmail.com> * use f words * small refactor * Update WebHostLib/generate.py Co-authored-by: qwint <qwint.42@gmail.com> * Fix whitespace. * Update one new use of seedError template for pickling errors. --------- Co-authored-by: qwint <qwint.42@gmail.com>
This commit is contained in:
committed by
GitHub
parent
8decde0370
commit
fd879408f3
@@ -72,6 +72,10 @@ def generate(race=False):
|
||||
return render_template("generate.html", race=race, version=__version__)
|
||||
|
||||
|
||||
def format_exception(e: BaseException) -> str:
|
||||
return f"{e.__class__.__name__}: {e}"
|
||||
|
||||
|
||||
def start_generation(options: dict[str, dict | str], meta: dict[str, Any]):
|
||||
results, gen_options = roll_options(options, set(meta["plando_options"]))
|
||||
|
||||
@@ -92,7 +96,11 @@ def start_generation(options: dict[str, dict | str], meta: dict[str, Any]):
|
||||
except PicklingError as e:
|
||||
from .autolauncher import handle_generation_failure
|
||||
handle_generation_failure(e)
|
||||
return render_template("seedError.html", seed_error=("PicklingError: " + str(e)))
|
||||
meta["error"] = format_exception(e)
|
||||
if e.__cause__:
|
||||
meta["source"] = format_exception(e.__cause__)
|
||||
details = json.dumps(meta, indent=4).strip()
|
||||
return render_template("seedError.html", seed_error=meta["error"], details=details)
|
||||
|
||||
commit()
|
||||
|
||||
@@ -104,7 +112,11 @@ def start_generation(options: dict[str, dict | str], meta: dict[str, Any]):
|
||||
except BaseException as e:
|
||||
from .autolauncher import handle_generation_failure
|
||||
handle_generation_failure(e)
|
||||
return render_template("seedError.html", seed_error=(e.__class__.__name__ + ": " + str(e)))
|
||||
meta["error"] = format_exception(e)
|
||||
if e.__cause__:
|
||||
meta["source"] = format_exception(e.__cause__)
|
||||
details = json.dumps(meta, indent=4).strip()
|
||||
return render_template("seedError.html", seed_error=meta["error"], details=details)
|
||||
|
||||
return redirect(url_for("view_seed", seed=seed_id))
|
||||
|
||||
@@ -175,9 +187,11 @@ def gen_game(gen_options: dict, meta: dict[str, Any] | None = None, owner=None,
|
||||
if gen is not None:
|
||||
gen.state = STATE_ERROR
|
||||
meta = json.loads(gen.meta)
|
||||
meta["error"] = (
|
||||
"Allowed time for Generation exceeded, please consider generating locally instead. " +
|
||||
e.__class__.__name__ + ": " + str(e))
|
||||
meta["error"] = ("Allowed time for Generation exceeded, " +
|
||||
"please consider generating locally instead. " +
|
||||
format_exception(e))
|
||||
if e.__cause__:
|
||||
meta["source"] = format_exception(e.__cause__)
|
||||
gen.meta = json.dumps(meta)
|
||||
commit()
|
||||
except BaseException as e:
|
||||
@@ -187,7 +201,9 @@ def gen_game(gen_options: dict, meta: dict[str, Any] | None = None, owner=None,
|
||||
if gen is not None:
|
||||
gen.state = STATE_ERROR
|
||||
meta = json.loads(gen.meta)
|
||||
meta["error"] = (e.__class__.__name__ + ": " + str(e))
|
||||
meta["error"] = format_exception(e)
|
||||
if e.__cause__:
|
||||
meta["source"] = format_exception(e.__cause__)
|
||||
gen.meta = json.dumps(meta)
|
||||
commit()
|
||||
raise
|
||||
@@ -204,7 +220,9 @@ def wait_seed(seed: UUID):
|
||||
if not generation:
|
||||
return "Generation not found."
|
||||
elif generation.state == STATE_ERROR:
|
||||
return render_template("seedError.html", seed_error=generation.meta)
|
||||
meta = json.loads(generation.meta)
|
||||
details = json.dumps(meta, indent=4).strip()
|
||||
return render_template("seedError.html", seed_error=meta["error"], details=details)
|
||||
return render_template("waitSeed.html", seed_id=seed_id)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user