Skip to content

Errors

In order to have full control over the tasks performed, it is necessary to know the errors from their traceback, screenshot or even in result files. Here we will cover how to create and send errors to the platform.

Create simple error

Using this method to create a simple error in Maestro.

try:
    div = 0 / 0
except Exception as error:
    maestro.error(task_id=task.id, exception=error)
try {
    int div = 0/0;
} catch (Exception error) {
    maestro.createError(task.id, error, null, null, null);
}
try {
    eval("hoo bar");
} catch (error) {
    await maestro.createError(task.id, error)
}
try {
    eval("hoo bar");
} catch (error: any) {
    await maestro.createError(task.id, error)
}

Customizable tags

In addition to having standard tags, it is possible to send customizable tags using the same method.

try:
    div = 0 / 0
except Exception as error:
    maestro.error(task_id=task.id, exception=error, tags={"custom": "tag"})
try {
    int div = 0/0;
} catch (Exception error) {
    Map<String, Object> tags = new HashMap<>();
    tags.put("custom", "tag");

    maestro.createError(task.id, error, null, tags, null);
}
try {
    eval("hoo bar");
} catch (error) {
    await maestro.createError(task.id, error, {"custom": "tag"})
}
try {
    eval("hoo bar");
} catch (error: any) {
    await maestro.createError(task.id, error, {"custom": "tag"})
}

Sending screenshot

It is possible to send the screenshot of the screen passing the file path.

try:
    div = 0 / 0
except Exception as error:
    filepath = '/home/test/screenshot.png'
    maestro.error(task_id=task.id, exception=error, screenshot=filepath)
try {
    int div = 0/0;
} catch (Exception error) {        
    File screenshot = new File("/home/test/screenshot.png");
    maestro.createError(task.id, error, screenshot, null, null);
}
try {
    eval("hoo bar");
} catch (error) {
    const filepath = '/home/test/screenshot.png'
    await maestro.createError(task.id, error, {}, filepath)
}
try {
    eval("hoo bar");
} catch (error: any) {
    const filepath: string = '/home/test/screenshot.png'
    await maestro.createError(task.id, error, {}, filepath)
}

Tip

You can easily save screenshots for Desktop and Web automations with the BotCity Frameworks.

Sending attachments

It is possible to send files to the error in Maestro, it must be done as follows:

try:
    div = 0 / 0
except Exception as error:
    attachments = ['/home/test/error.png', '/home/test/test.txt']
    maestro.error(task_id=task.id, exception=error, attachments=attachments)
try {
    int div = 0/0;
} catch (Exception error) {
    List<File> attachments = new ArrayList<>();
    attachments.add(new File("/home/test/error.png"));
    attachments.add(new File("/home/test/test.txt"));

    maestro.createError(task.id, error, null, null, attachments);
}
try {
    eval("hoo bar");
} catch (error) {
    const attachments = ['/home/test/file.txt', '/home/test/file2.txt']
    await maestro.createError(task.id, error, {}, '', attachments)
}
try {
    eval("hoo bar");
} catch (error: any) {
    const attachments: string[] = ['/home/test/file.txt', '/home/test/file2.txt']
    await maestro.createError(task.id, error, {}, '', attachments)
}