<commit_before>'use strict';
/*
 * Copyright 2013 Next Century Corporation
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

var error = error || {};

error.UNKNOWN_ERROR_MESSAGE = "An error occurred.";

// Customize the error message that is shown based on the error code returned by the neon-server.
error.ERROR_CODE_TO_MESSAGE = {
    // aggregation result exceeds maximum document size (16MB)
    "16389": "Query execution failed because there was too much data."
};

// Store the stack trace text for each individual error so we don't have to insert it into the HTML.
// We'll delete it when we're finished with it.
error.STACK_TRACE_STORAGE = {};
error.STACK_TRACE_NEXT_INDEX = 1;

$.notify.addStyle("error", {
    html:
        // The first div gets reclassed by notifyjs.
        "<div>" +
            // Store the stack trace index corresponding to this error.
            "<span data-notify-text='index' class='index hidden'></span>" +
            // Add the notifyjs bootstrap styling.
            "<div class='notifyjs-bootstrap-base notifyjs-bootstrap-error'>" +
                "<div class='message' data-notify-text='message'/>" +
                "<div class='buttons'>" +
                    "<button class='btn btn-default pull-right' onclick=\"error.showStackTraceNotification_(this.parentElement.parentElement.parentElement);\">" +
                        "Details" +
                    "</button>" +
                    "<button class='btn btn-default pull-right' onclick=\"error.hideErrorNotification_(this.parentElement.parentElement.parentElement);\">" +
                        "OK" +
                    "</button>" +
                    "<div class='clearfix'></div>" +
                "</div>" +
            "</div>" +
        "</div>"
});

$.notify.addStyle("stacktrace", {
    html:
        // The first div gets reclassed by notifyjs.
        "<div>" +
            // Add the notifyjs bootstrap styling.
            "<div class='notifyjs-bootstrap-base notifyjs-bootstrap-error'>" +
                "<div class='stacktrace well' data-notify-html='stacktrace'/>" +
            "</div>" +
        "</div>"
});

/**
 * Shows an error message popup for the given parameters.
 * @param {HTMLElement} The notification will be displayed next to this element.
 * @param {Integer} The error code corresponding to the error message that will be displayed.
 * @param {String} The error stack trace.
 * @return The jQuery element for the error message.
 */
error.showErrorMessage = function(htmlElement, errorCode, stackTrace) {
    var jqueryElement = $(htmlElement);

    var message = error.ERROR_CODE_TO_MESSAGE[errorCode] ? error.ERROR_CODE_TO_MESSAGE[errorCode] : error.UNKNOWN_ERROR_MESSAGE;
    var index = error.STACK_TRACE_NEXT_INDEX++;
    error.STACK_TRACE_STORAGE[index] = stackTrace;

    // Show a temporary notification in the corner of the dashboard.
    $.notify(message);<commit_msg>NEON-1355 Changing the show error notification function to accept an error message instead of an error code.<commit_after>'use strict';
/*
 * Copyright 2013 Next Century Corporation
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

var error = error || {};

error.UNKNOWN_ERROR_MESSAGE = "An error occurred.";

// Store the stack trace text for each individual error so we don't have to insert it into the HTML.
// We'll delete it when we're finished with it.
error.STACK_TRACE_STORAGE = {};
error.STACK_TRACE_NEXT_INDEX = 1;

$.notify.addStyle("error", {
    html:
        // The first div gets reclassed by notifyjs.
        "<div>" +
            // Store the stack trace index corresponding to this error.
            "<span data-notify-text='index' class='index hidden'></span>" +
            // Add the notifyjs bootstrap styling.
            "<div class='notifyjs-bootstrap-base notifyjs-bootstrap-error'>" +
                "<div class='message' data-notify-text='message'/>" +
                "<div class='buttons'>" +
                    "<button class='btn btn-default pull-right' onclick=\"error.showStackTraceNotification_(this.parentElement.parentElement.parentElement);\">" +
                        "Details" +
                    "</button>" +
                    "<button class='btn btn-default pull-right' onclick=\"error.hideErrorNotification_(this.parentElement.parentElement.parentElement);\">" +
                        "OK" +
                    "</button>" +
                    "<div class='clearfix'></div>" +
                "</div>" +
            "</div>" +
        "</div>"
});

$.notify.addStyle("stacktrace", {
    html:
        // The first div gets reclassed by notifyjs.
        "<div>" +
            // Add the notifyjs bootstrap styling.
            "<div class='notifyjs-bootstrap-base notifyjs-bootstrap-error'>" +
                "<div class='stacktrace well' data-notify-html='stacktrace'/>" +
            "</div>" +
        "</div>"
});

/**
 * Shows an error message popup for the given parameters.
 * @param {HTMLElement} The notification will be displayed next to this element.
 * @param {String} The error message that will be displayed in the notification.
 * @param {String} The error stack trace.
 * @return The jQuery element for the error message.
 */
error.showErrorMessage = function(htmlElement, message, stackTrace) {
    var jqueryElement = $(htmlElement);

    var index = error.STACK_TRACE_NEXT_INDEX++;
    error.STACK_TRACE_STORAGE[index] = stackTrace;

    // Show a temporary notification in the corner of the dashboard.
    $.notify(message);
{'fraction_non_alphanumeric': 0.11387574416119677, 'fraction_numerical': 0.00442680506792856, 'mean_word_length': 2.6685330347144456, 'pattern_counts': {'":': 1, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7423259', 'n_tokens_mistral': 1724, 'n_tokens_neox': 1678, 'n_words': 596}