Skip to content
This repository has been archived by the owner on Aug 28, 2022. It is now read-only.

No stacktrace in error message #227

Open
xuanzhaopeng opened this issue Aug 6, 2021 · 0 comments
Open

No stacktrace in error message #227

xuanzhaopeng opened this issue Aug 6, 2021 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@xuanzhaopeng
Copy link

Describe the bug

We just show error messages, but somehow we ignored the stacktrace which increased the investigation time

I would suggest to update handleError function

    handleError(error) {
        var _a;
        if (Array.isArray(error)) {
            // Test_done event sends an array of arrays containing errors.
            error = _.flattenDeep(error)[0];
        }
        let status = allure_js_commons_1.Status.BROKEN;
        let message = error.name;
        let trace = error.stack || error.message; // I changed here
        if (error.matcherResult) {
            status = allure_js_commons_1.Status.FAILED;
            const matcherMessage = typeof error.matcherResult.message === 'function' ? error.matcherResult.message() : error.matcherResult.message;
            const [line1, line2, ...restOfMessage] = matcherMessage.split('\n');
            message = [line1, line2].join('\n');
            trace = error.stack || restOfMessage.join('\n');  // I changed here
        }
        if (!message && trace) {
            message = trace;
            trace = (_a = error.stack) === null || _a === void 0 ? void 0 : _a.replace(message, 'No stack trace provided');
        }
        if (trace === null || trace === void 0 ? void 0 : trace.includes(message)) {
            trace = trace === null || trace === void 0 ? void 0 : trace.replace(message, '');
        }
        if (!message) {
            message = 'Error. Expand for more details.';
            trace = error;
        }
        return {
            status,
            message: stripAnsi(message),
            trace: stripAnsi(trace)
        };
    }
@xuanzhaopeng xuanzhaopeng added the bug Something isn't working label Aug 6, 2021
@ryparker ryparker added this to the V2.0 milestone Aug 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants