Exemple #1
0
static void
show_last_error_and_exit(Parrot_PMC interp)
{
    Parrot_Int    is_error,
                  exit_code;
    Parrot_String errmsg,
                  backtrace;
    Parrot_PMC    exception;

    /* Get result of last API function call and exception backtrace */
    if (!(Parrot_api_get_result(interp, &is_error, &exception, &exit_code, &errmsg)
        && Parrot_api_get_exception_backtrace(interp, exception, &backtrace))) {

        fprintf(stderr, "PARROT VM: Cannot recover\n");
        exit(EXIT_FAILURE);
    }

    /* Check for unhandled exceptions */
    if (is_error) {
        char *msg;

        /* Display error message */
        Parrot_api_string_export_ascii(interp, errmsg, &msg);
        fprintf(stderr, "%s\n", msg);
        Parrot_api_string_free_exported_ascii(interp, msg);

        /* Display exception backtrace */
        Parrot_api_string_export_ascii(interp, backtrace, &msg);
        fprintf(stderr, "%s\n", msg);
        Parrot_api_string_free_exported_ascii(interp, msg);
    }

    exit(exit_code);
}
Exemple #2
0
static void
show_last_error_and_exit(Parrot_PMC interp)
{
    Parrot_String errmsg, backtrace;
    Parrot_Int exit_code, is_error;
    Parrot_PMC exception;

    if (!(Parrot_api_get_result(interp, &is_error, &exception, &exit_code, &errmsg) &&
            Parrot_api_get_exception_backtrace(interp, exception, &backtrace))) {
        fprintf(stderr, "PARROT VM: Cannot recover\n");
        exit(EXIT_FAILURE);
    }

    if (errmsg) {
        char * errmsg_raw;
        Parrot_api_string_export_ascii(interp, errmsg, &errmsg_raw);
        fprintf(stderr, "%s\n", errmsg_raw);
        Parrot_api_string_free_exported_ascii(interp, errmsg_raw);

        Parrot_api_string_export_ascii(interp, backtrace, &errmsg_raw);
        fprintf(stderr, "%s\n", errmsg_raw);
        Parrot_api_string_free_exported_ascii(interp, errmsg_raw);
    }
    exit(exit_code);
}
Exemple #3
0
/**
 * The calling signature on this thing is so incredibly wrong.
 * This function SHOULD have been passed the route and the exception,
 * and perhaps the request as well.
 *
 * Instead it gets the exception for itself, just dumping the backtrace
 * (w/o proper information) in the server error log. I'd really like to fix
 * this one day.
 *
 * @param Parrot_PMC interp The interpreter on which the error occured
 * @param request_rec * req The request on which the error occured.
 * @return int the http code of the error (HTTP_INTERNAL_SERVER_ERROR)
 **/
apr_status_t mod_parrot_report(Parrot_PMC interp, request_rec *req) {
    Parrot_Int is_error, exit_code;
    Parrot_PMC exception;
    Parrot_String error_message, backtrace;
    if (Parrot_api_get_result(interp, &is_error, &exception, &exit_code, &error_message) && is_error) {
        /* do something useful on the basis of this information */
        char *rrmsg,  *bcktrc;
        Parrot_api_get_exception_backtrace(interp, exception, &backtrace);
        Parrot_api_string_export_ascii(interp, error_message, &rrmsg);
        Parrot_api_string_export_ascii(interp, backtrace, &bcktrc);
        fputs(rrmsg, stderr);
        fputs(bcktrc, stderr);
    }
    /**
     * This right here, is pretty much wrong
     **/
    return HTTP_INTERNAL_SERVER_ERROR;
}
Exemple #4
0
static void
show_last_error_and_exit(Parrot_PMC interp)
{
    ASSERT_ARGS(show_last_error_and_exit)
    Parrot_String errmsg, backtrace;
    Parrot_Int exit_code, is_error;
    Parrot_PMC exception;

    if (!Parrot_api_get_result(interp, &is_error, &exception, &exit_code, &errmsg))
        exit(EXIT_FAILURE);
    if (is_error) {
        if (!Parrot_api_get_exception_backtrace(interp, exception, &backtrace))
            exit(EXIT_FAILURE);
        print_parrot_string(interp, stderr, errmsg, 1);
        print_parrot_string(interp, stderr, backtrace, 0);
    }

    exit(exit_code);
}