export function logException(ex, context) { Raven.captureException(ex, { extra: context, }); /* eslint no-console:0 */ /* eslint no-unused-expressions:0 */ window && window.console && console.error && console.error(ex); }
/** * @param {error} Error - an error that tells us when loading has failed */ loadingFailed(error) { this.setState({ errorMessage: error.message, error: error, loading: false }) Raven.captureException(error, this.state); }
}, err => { if (err) { dispatch(uiActions.addNotification({ message: 'Erro installing plugins.', level: 'error' })) Raven.captureException(err) } })
}, (err, res, body) => { if (err) { return Raven.captureException(err); } const view = new ViewConstructor(Object.assign(viewOptions, body)); router.trigger("newPage", view); });
always: (err) => { if (err) { return Raven.captureException(err); } const piece = pieces.get(id); if (!piece) { return Raven.captureException(new Error("Piece not found")); } const view = new ASeriesPiecePage({ model: piece, collection: pieces }); piece.preloadImages(() => router.trigger("newPage", view)); }
async play() { if (this._status !== STATUS.PAUSED) { this.seekToTime(0); } try { await this._audio.play(); } catch (err) { Raven.captureException(err); } this._setStatus(STATUS.PLAYING); }
.run((err) => { if (err) { dispatch(uiActions.addNotification({ message: 'Plugin update error.', level: 'error' })) Raven.captureException(err) } else { dispatch(toggleIsInstalling(index)) dispatch(install(plugin, index)) } })
npmi(options, err => { if (err) { dispatch(uiActions.addNotification({ message: 'Plugin install error.', level: 'error' })) return Raven.captureException(err) } else { // eslint-disable-line dispatch(fetchInstalled()) dispatch(toggleIsInstalling(index)) } })
responseError: function responseError(rejection) { if (rejection.status >= 500 && rejection.status < 600) { Raven.captureException(new Error('HTTP response error'), { tags: {component: 'server'}, extra: { status: rejection.status, request: rejection.config, response: rejection.data } }); } return $q.reject(rejection); }
const register = unhandledRejection => unhandledRejection(event => { event.preventDefault(); const { reason: error } = event.detail; if (process.env.NODE_ENV === 'production') { // "error.reason || error" because redux-promise-middleware Raven.captureException(error.reason || error); // We can use also Raven.lastEventId() and Raven.showReportDialog(). // Check docs.getsentry.com/hosted/clients/javascript/usage } else { /* eslint-disable no-console */ console.warn('Unhandled promise rejection. Fix it or it will be reported.'); console.warn(JSON.parse(JSON.stringify(error))); /* eslint-enable no-console */ } });
this._getASeries(seriesSlug, (err, seriesModel) => { if (err) { return Raven.captureException(err); } const view = new ASeriesPage({ model: seriesModel }); seriesModel.pieces.fetch({ always: () => { seriesModel.pieces.preloadThumbnails(() => router.trigger("newPage", view)); } }); });
return store => next => action => { try { Raven.captureBreadcrumb({ data: { redux: action.type }, }) return next(action) } catch (err) { console.error('[octoblu-raven] Reporting error to Sentry:', err) Raven.captureException(err, { extra: { action, state: store.getState(), }, }) } }
/** * Report an error to Sentry. * * @param {Error} error - An error object describing what went wrong * @param {string} when - A string describing the context in which * the error occurred. * @param {Object} [context] - A JSON-serializable object containing additional * information which may be useful when * investigating the error. */ function report(error, when, context) { if (!(error instanceof Error)) { // If the passed object is not an Error, raven-js // will serialize it using toString() which produces unhelpful results // for objects that do not provide their own toString() implementations. // // If the error is a plain object or non-Error subclass with a message // property, such as errors returned by chrome.extension.lastError, // use that instead. if (typeof error === 'object' && error.message) { error = error.message; } } var extra = Object.assign({ when: when }, context); Raven.captureException(error, { extra: extra }); }
/* * `expand` takes a translated string and * (1) interpolates values (React nodes) into it, * (2) converts HTML to React elements. * * The output is intended for use with React, so the result is a valid * React node (a string, a React element, or null). * * A (safe) subset of HTML is supported, in addition to the variable * substitution syntax. In order to display a character reserved by * either syntax, HTML character entities must be used. */ export default function expand(source: string, args?: ?VarArgs): React.Node { // Reset the global state. state.args = args; state.match = ''; state.position = 0; state.remainder = source; state.replacement = NO_MATCH; state.source = source; state.textPattern = textContent; let result; try { result = parseRoot(); if (state.remainder) { throw error('unexpected token'); } } catch (e) { /* * If we can't parse the string, just return the source string back * so that the page doesn't break. But also log the error to the * console and Sentry. */ console.error(e); Raven.captureException(e); return source; } finally { // Remove reference to the args object, so it can be GC'd. state.args = EMPTY_OBJECT; } return result.length ? ( result.length > 1 ? React.createElement(React.Fragment, null, ...result) : result[0] ) : ''; }
.end((err, res) => { if (err) { dispatch(uiActions.addNotification({ message: 'Could not fetch plugins', level: 'error' })) Raven.captureException(err) return } const p = _.map(res.body.aaData, r => ({ name: r.name, version: r.version, description: r.description, author: r.author, modified: r.modified, downloads: r.dl, homepage: r.homepage, readme: r.readme, })) dispatch(setRegistry(p)) dispatch(toggleIsSearching()) })
var processCallback = function() { try { var finalViewportOffset = getElementViewportOffset(elReference, scrollableElement), differenceToTargetOffset = finalViewportOffset - desiredViewportOffset; if(debugScrollUtils) { console.log("scrollUtils::scrollToElement(): Final viewPort offset: ", finalViewportOffset, ", difference of: ", differenceToTargetOffset, " with desiredViewportOffset of ", desiredViewportOffset); } if (animate && differenceToTargetOffset !== 0) { if(debugScrollUtils) { console.log("scrollUtils::scrollToElement(): differenceToTargetOffset is not 0. The content above the element may well have changed length during animation, retry scrolling with no animation"); } var scrollTarget = computeScrollTarget(elReference, scrollableElement, desiredViewportOffset); scrollableElement.scrollTop(scrollTarget); if(debugScrollUtils) { console.log("scrollUtils::scrollToElement(): POST_RETRY Final viewPort offset: ", getElementViewportOffset(el, scrollableElement), ", difference to target offset: ", getElementViewportOffset(el, scrollableElement) - desiredViewportOffset, " target scrollTop was ", scrollTarget, "final scrollTop is ", scrollableElement.scrollTop()); } } if (_.isFunction(callback)) { callback(); } if(watch) { _watchOffset(el, scrollableElement); } } catch (e) { if (sentry_dsn) { Raven.captureException(e); } else { throw e; } } }
error (err) { Raven.captureException(err) console.error('Exception to Report:', err) }
SentryExceptionHandler.prototype.call = function (exception, stackTrace, reason) { Raven.captureException(exception); console.log(exception, stackTrace, reason); };
componentDidCatch(error) { // Display fallback UI this.setState({ hasError: true, errorMessage: error.toString() }); // You can also log the error to an error reporting service Raven.captureException(error); }
function start() { analytics.initialise(); var options = require('options'); var subdomainPart = window.location.hostname.split('.')[0]; var langBySubdomain = _.find(options.languages, function (lang) { return lang.id === subdomainPart || lang.alias.indexOf(subdomainPart) >= 0; }); var subLangId = langBySubdomain ? langBySubdomain.id : undefined; var defaultConfig = { settings: {showPopoutIcon: false}, content: [{ type: 'row', content: [ Components.getEditor(1, subLangId), Components.getCompiler(1, subLangId) ] }] }; $(window).bind('hashchange', function () { // punt on hash events and just reload the page if there's a hash if (window.location.hash.substr(1)) window.location.reload(); }); var config; if (!options.embedded) { config = url.deserialiseState(window.location.hash.substr(1)); if (config) { // replace anything in the default config with that from the hash config = _.extend(defaultConfig, config); } if (!config) { var savedState = local.get('gl', null); config = savedState !== null ? JSON.parse(savedState) : defaultConfig; } } else { config = _.extend(defaultConfig, {settings: { showMaximiseIcon: false, showCloseIcon: false, hasHeaders: false }}, sharing.configFromEmbedded(window.location.hash.substr(1))); } var root = $("#root"); var layout; var hub; try { layout = new GoldenLayout(config, root); hub = new Hub(layout, subLangId); } catch (e) { Raven.captureException(e); layout = new GoldenLayout(defaultConfig, root); hub = new Hub(layout, subLangId); } layout.on('stateChanged', function () { var config = layout.toConfig(); // Only preserve state in localStorage in non-embedded mode. if (!options.embedded) { local.set('gl', JSON.stringify(config)); } else { var strippedToLast = window.location.pathname; strippedToLast = strippedToLast.substr(0, strippedToLast.lastIndexOf('/') + 1); $('a.link').attr('href', strippedToLast + '#' + url.serialiseState(config)); } }); function sizeRoot() { var height = $(window).height() - (root.position().top || 0); root.height(height); layout.updateSize(); } $(window).resize(sizeRoot); sizeRoot(); new clipboard('.btn.clippy'); setupSettings(hub); sharing.initShareButton($('#share'), layout); function setupAdd(thing, func) { layout.createDragSource(thing, func); thing.click(function () { hub.addAtRoot(func()); }); } var alertSystem = new Alert(); setupAdd($('#add-diff'), function () { return Components.getDiff(); }); setupAdd($('#add-editor'), function () { return Components.getEditor(); }); $('#ui-reset').click(function () { local.remove('gl'); window.location.reload(); }); $('#thanks-to').click(function () { alertSystem.alert("Special thanks to", $(require('./thanks.html'))); }); $('#changes').click(function () { alertSystem.alert("Changelog", $(require('./changelog.html'))); }); }
}, function (error) { Raven.captureException(error); originalConsole(error); });
export function logException(ex,context) { Raven.captureException(ex,{ extra:context }); window && window.console && console.error && console.error(ex); }
/* * This is not meant to be called directly, except by expand2react and * expand2text. These functions accept an args hash containing values * of type V, and produce an expansion result of type T. * * So in the case of expand2react, the types would be: * expand<string | React.Element<any>, string | number | React.Element<any>>; * * And for expand2text they'd be: * expand<string, string | number>; * * Thus these signatures provide type safety on both the return value * and input arg values. */ export default function expand<+T, V>( rootParser: (VarArgs<V>) => T, source: ?string, args: ?(VarArgsObject<V> | VarArgs<V>), ): T | string { if (!source) { return ''; } let savedState; if (state.running) { savedState = {...state}; } // Reset the global state. state.match = ''; state.position = 0; state.remainder = source; state.replacement = NO_MATCH_VALUE; state.running = true; state.source = source; if (!(args instanceof VarArgs)) { /* * Note: The `data` property is covariant on the VarArgs class, * but assigning to it here is safe only because it remains * constant throughout the `expand` call, so this is equivalent * to creating a new object. It must not be assigned to anywhere * else. */ (DEFAULT_ARGS: any).data = args || EMPTY_OBJECT; args = (DEFAULT_ARGS: VarArgs<V>); } let result; try { result = rootParser(args); if (state.remainder) { throw error('unexpected token'); } } catch (e) { /* * If we can't parse the string, just return the source string back * so that the page doesn't break. But also log the error to the * console and Sentry. */ console.error(e); Raven.captureException(e); return source; } finally { if (savedState) { Object.assign(state, savedState); } else { state.running = false; // Remove reference to the args object, so it can be GC'd. (DEFAULT_ARGS: any).data = EMPTY_OBJECT; } } return result; }
export function captureException(exception, options) { if (process.env.NODE_ENV === 'production') { Raven.captureException(exception, options); } }
? e => Raven.captureException(e)
window.addEventListener('unhandledrejection', (e) => { // Send error message and stack Raven.captureException(e.reason.message, { extra: { stack: e.reason.stack } }); });
window.addEventListener('error', (e) => { // Send error message and stack Raven.captureException(e.message, { extra: { stack: e.error.stack } }); });
.catch(function(e) { Raven.captureException(e); });
window.addEventListener('unhandledrejection', (evt) => { Raven.captureException(evt.reason); });
$provide.factory('$exceptionHandler', () => function errorCatcherHandler(exception, cause) { Raven.captureException(exception, {tags: {component: 'ui'}, extra: exception}); });