Send errors to sentry

This commit is contained in:
Hannu Lyytikainen 2017-09-27 10:48:52 +03:00
parent d46e4cdfc5
commit 5bf9d0f072
7 changed files with 25 additions and 16 deletions

View file

@ -156,7 +156,7 @@ app.get('*', (req, res) => {
}
})
.catch(e => {
console.error(e);
log.error(e);
res.status(500).send(errorPage);
});
});

View file

@ -6,6 +6,7 @@ import { NotFoundPage } from './containers';
import { NamedRedirect } from './components';
import { withFlattenedRoutes } from './util/contextHelpers';
import * as propTypes from './util/propTypes';
import { error as logError } from './util/log';
const { bool, arrayOf, object, func, shape, string, any } = PropTypes;
@ -29,8 +30,7 @@ const callLoadData = props => {
console.log(`loadData success for ${name} route`);
})
.catch(e => {
// eslint-disable-next-line no-console
console.error(`loadData error for ${name} route`, e);
logError(e, { route: route });
});
}
};

View file

@ -8,7 +8,7 @@ import classNames from 'classnames';
import { types } from '../../util/sdkLoader';
import { formatMoney } from '../../util/currency';
import * as propTypes from '../../util/propTypes';
import * as log from '../../util/log';
import { error as logError } from '../../util/log';
import css from './BookingBreakdown.css';
@ -78,10 +78,14 @@ export const BookingBreakdownComponent = props => {
if (isProvider) {
if (!isValidCommission(providerCommissionLineItem)) {
log.error(
new Error('Commission should be present and the value should be zero or negative'),
{ providerCommissionLineItem: providerCommissionLineItem, transaction: transaction }
const error = new Error(
'Commission should be present and the value should be zero or negative'
);
logError(error, {
providerCommissionLineItem: providerCommissionLineItem,
transaction: transaction,
});
throw error;
}
// The total sum that the customer pays is the payinTotal. We use

View file

@ -20,6 +20,7 @@ import {
truncateToSubUnitPrecision,
} from '../../util/currency';
import * as propTypes from '../../util/propTypes';
import { error as logError } from '../../util/log';
import css from './CurrencyInputField.css';
@ -81,9 +82,7 @@ class CurrencyInputComponent extends Component {
usesComma,
};
} catch (e) {
// Print error, if default value isn't supported (see specs: truncateToSubUnitPrecision).
// eslint-disable-next-line no-console
console.error('CurrencyInput:', e);
logError(e, { props: props });
throw e;
}

View file

@ -2,6 +2,7 @@ import React, { Component, PropTypes } from 'react';
import { FormattedMessage } from 'react-intl';
import classNames from 'classnames';
import { Promised } from '../../components';
import { error as logError } from '../../util/log';
import css from './ImageFromFile.css';
@ -12,9 +13,9 @@ const readImage = file =>
const reader = new FileReader();
reader.onload = e => resolve(e.target.result);
reader.onerror = e => {
// eslint-disable-next-line
console.error('Error (', e, `) happened while reading ${file.name}: ${e.target.result}`);
reject(new Error(`Error reading ${file.name}: ${e.target.result}`));
const error = new Error(`Error reading ${file.name}: ${e.target.result}`);
logError(error, { file: file });
reject(error);
};
reader.readAsDataURL(file);
});

View file

@ -11,6 +11,7 @@ import { googleLatLngToSDKLatLng, googleBoundsToSDKBounds } from '../../util/goo
import { createResourceLocatorString } from '../../util/routes';
import { createSlug, parse, stringify } from '../../util/urlHelpers';
import * as propTypes from '../../util/propTypes';
import { error as logError } from '../../util/log';
import { getListingsById } from '../../ducks/marketplaceData.duck';
import { sendVerificationEmail } from '../../ducks/user.duck';
import { logout, authenticationInProgress } from '../../ducks/Auth.duck';
@ -124,8 +125,11 @@ export class SearchPageComponent extends Component {
})
.catch(error => {
// In case of error, stop recursive loop and report error.
// TODO: Show a flash message
// eslint-disable-next-line no-console
console.error(`An error (${error} occured while trying to retrieve map listings`);
logError(new Error(error));
});
}

View file

@ -41,7 +41,7 @@ const render = store => {
ReactDOM.render(<ClientApp store={store} />, document.getElementById('root'));
})
.catch(e => {
console.error(e); // eslint-disable-line
log.error(e);
});
};
@ -55,6 +55,9 @@ const setupStripe = () => {
// If we're in a browser already, render the client application.
if (typeof window !== 'undefined') {
// set up logger with Sentry DSN client key and environment
log.setup(config.sentryDsn, config.env);
// eslint-disable-next-line no-underscore-dangle
const preloadedState = window.__PRELOADED_STATE__ || '{}';
const initialState = JSON.parse(preloadedState, types.reviver);
@ -74,8 +77,6 @@ if (typeof window !== 'undefined') {
setupStripe();
render(store);
// set up logger with Sentry DSN client key and environment
log.setup(config.sentryDsn, config.env);
if (config.dev) {
// Expose stuff for the browser REPL