X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=.config%2Fcoc%2Fextensions%2Fnode_modules%2Fcoc-prettier%2Flib%2FerrorHandler.js;fp=.config%2Fcoc%2Fextensions%2Fnode_modules%2Fcoc-prettier%2Flib%2FerrorHandler.js;h=0000000000000000000000000000000000000000;hb=3ddadb3c98564791f0ac36cb39771d844a63dc91;hp=71870acfa850f79f29edb17c6da5d1c8e23a1a3b;hpb=5f797af6612ed10887189b47a1efc2f915586e59;p=dotfiles%2F.git diff --git a/.config/coc/extensions/node_modules/coc-prettier/lib/errorHandler.js b/.config/coc/extensions/node_modules/coc-prettier/lib/errorHandler.js deleted file mode 100644 index 71870acf..00000000 --- a/.config/coc/extensions/node_modules/coc-prettier/lib/errorHandler.js +++ /dev/null @@ -1,82 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const coc_nvim_1 = require("coc.nvim"); -let outputChannel; -/** - * Adds the filepath to the error message - * - * @param msg The original error message - * @param fileName The path to the file - * @returns {string} enhanced message with the filename - */ -function addFilePath(msg, fileName) { - const lines = msg.split('\n'); - if (lines.length > 0) { - lines[0] = lines[0].replace(/(\d*):(\d*)/g, `${fileName}:$1:$2`); - return lines.join('\n'); - } - return msg; -} -/** - * Append messages to the output channel and format it with a title - * - * @param message The message to append to the output channel - */ -function addToOutput(message, type = 'Trace') { - if (!outputChannel) - return; - const title = `${type} - ${new Date().toLocaleString()}:`; - // Create a sort of title, to differentiate between messages - outputChannel.appendLine(''); - // Append actual output - outputChannel.appendLine(`[${title}] ${message}\n`); -} -exports.addToOutput = addToOutput; -/** - * Execute a callback safely, if it doesn't work, return default and log messages. - * - * @param cb The function to be executed, - * @param defaultText The default value if execution of the cb failed - * @param fileName The filename of the current document - * @returns {string} formatted text or defaultText - */ -function safeExecution(cb, defaultText, fileName) { - if (cb instanceof Promise) { - return cb - .then(returnValue => { - // updateStatusBar('Prettier: $(check)') - return returnValue; - }) - .catch((err) => { - addToOutput(addFilePath(err.message, fileName), 'Error'); - // updateStatusBar('Prettier: $(x)') - return defaultText; - }); - } - try { - const returnValue = cb(); - // updateStatusBar('Prettier: $(check)') - return returnValue; - } - catch (err) { - addToOutput(addFilePath(err.message, fileName), 'Error'); - // updateStatusBar('Prettier: $(x)') - return defaultText; - } -} -exports.safeExecution = safeExecution; -/** - * Setup the output channel and the statusBarItem. - * Create a command to show the output channel - * - * @returns {Disposable} The command to open the output channel - */ -function setupErrorHandler() { - // Setup the outputChannel - outputChannel = coc_nvim_1.workspace.createOutputChannel('prettier'); - return coc_nvim_1.commands.registerCommand('prettier.open-output', () => { - outputChannel.show(); - }); -} -exports.setupErrorHandler = setupErrorHandler; -//# sourceMappingURL=errorHandler.js.map \ No newline at end of file