How to use the js-cookie/src/js.cookie.get function in js-cookie

To help you get started, we’ve selected a few js-cookie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github datenanfragen / website / src / error-handler.js View on Github external
function logError(event) {
    console.log('%cAn unexpected error occurred:', 'color: red; font-weight: bold;', event, 'Please submit reports via GitHub ( or email (');

let debugging_enabled = false;
try {
    let cookie = require('js-cookie/src/js.cookie');
    debugging_enabled = !!cookie.get('debugging_enabled');
catch(e) {}

try {
    let preact = require('preact');
    let Modal = require('Components/Modal').default;
    let t  = require('Utility/i18n').default;

    window.addEventListener('error', event => {

        // This is horrendous. It is however the easiest (and worryingly cleanest) way I see to achieve the intended result here as the (interesting) properties of the `Error` object are not enumerable and JSON.stringify() only encodes enumerable properties.
        let debug_info = JSON.parse(JSON.stringify(event, [ 'code', 'message', 'description', 'arguments', 'type', 'name', 'colno', 'filename', 'lineno', 'error', 'stack', 'enduser_message' ]));

        // It gets worse. Errors in Chrome have basically no information at all, not even a code or error type.
        // TODO: Since the Chrome debug info contains practically no information at all, we should probably include a note that users would need to manually copy the stack trace from the console in order for us to be able to do anything.