Currently when an exception is raised within an event handler, that error is only displayed in the console but not in Minecraft.
It would be nice to have a report_error decorator for such functions. This function could have parameters where the exception types could be restricted. This decorator should be able to be applied on any async function that accepts a Context as the first parameter.
As of now you would need to implement that decorator yourself or use a large try-except block around the entire logic.
Examples
from bedrock.server import Server
from bedrock.ext.ui import report_error
app = Server()
@app.game_event
@report_error # same as `@report_error(when={Exception})`
async def player_message(ctx):
...
from bedrock.server import Server
from bedrock.ext.ui import report_error
app = Server()
@app.game_event
@report_error(when={ZeroDivisionError}) # only report `ZeroDivisionError`s
async def player_message(ctx):
...
from bedrock.server import Server
from bedrock.ext.ui import report_error
app = Server()
@app.game_event
@report_error(unless={ZeroDivisionError, OverflowError}) # report everything except `ZeroDivisionError`s and `OverflowError`s
async def player_message(ctx):
...
Currently when an exception is raised within an event handler, that error is only displayed in the console but not in Minecraft.
It would be nice to have a
report_errordecorator for such functions. This function could have parameters where the exception types could be restricted. This decorator should be able to be applied on any async function that accepts aContextas the first parameter.As of now you would need to implement that decorator yourself or use a large try-except block around the entire logic.
Examples