Skip to content

[💡 Idea]: automatic error reporting #8

Description

@phoenixr-codes

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):
    ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions