Add error logging

This commit is contained in:
Hannu Lyytikainen 2017-09-27 14:45:40 +03:00
parent 796bf17c93
commit f95702c313
4 changed files with 21 additions and 11 deletions

View file

@ -1,6 +1,7 @@
import { pick } from 'lodash';
import { updatedEntities, denormalisedEntities } from '../../util/data';
import * as propTypes from '../../util/propTypes';
import { error as logError } from '../../util/log';
import { fetchCurrentUserHasOrdersSuccess } from '../../ducks/user.duck';
// ================ Action types ================ //
@ -119,6 +120,7 @@ export const initiateOrder = params =>
})
.catch(e => {
dispatch(initiateOrderError(e));
logError(e);
throw e;
});
};
@ -160,5 +162,8 @@ export const speculateTransaction = (listingId, bookingStart, bookingEnd) =>
const tx = denormalised[0];
dispatch(speculateTransactionSuccess(tx));
})
.catch(e => dispatch(speculateTransactionError(e)));
.catch(e => {
logError(e);
return dispatch(speculateTransactionError(e));
});
};

View file

@ -1,5 +1,6 @@
import { omit, omitBy, isUndefined } from 'lodash';
import { types } from '../../util/sdkLoader';
import { error as logError } from '../../util/log';
import { addMarketplaceEntities } from '../../ducks/marketplaceData.duck';
import { fetchCurrentUserHasListingsSuccess } from '../../ducks/user.duck';
@ -80,8 +81,6 @@ export default function reducer(state = initialState, action = {}) {
redirectToListing: true,
};
case CREATE_LISTING_ERROR:
// eslint-disable-next-line no-console
console.error(payload);
return {
...state,
createListingInProgress: false,
@ -94,8 +93,6 @@ export default function reducer(state = initialState, action = {}) {
case UPDATE_LISTING_SUCCESS:
return { ...state, updateInProgress: false };
case UPDATE_LISTING_ERROR:
// eslint-disable-next-line no-console
console.error(payload);
return { ...state, updateInProgress: false, updateListingError: payload };
case SHOW_LISTINGS_REQUEST:
@ -282,7 +279,10 @@ export function requestCreateListing(data) {
dispatch(fetchCurrentUserHasListingsSuccess(true));
return response;
})
.catch(e => dispatch(createListingError(e)));
.catch(e => {
logError(e, { listingData: cleanedData });
return dispatch(createListingError(e));
});
};
}
@ -318,7 +318,10 @@ export function requestUpdateListing(tab, data) {
dispatch(markTabUpdated(tab));
dispatch(updateListingSuccess(updateResponse));
})
.catch(e => dispatch(updateListingError(e)));
.catch(e => {
logError(e, { listingData: cleanedData });
return dispatch(updateListingError(e));
});
};
}

View file

@ -1,4 +1,5 @@
import { types } from '../../util/sdkLoader';
import { error as logError } from '../../util/log';
import { addMarketplaceEntities } from '../../ducks/marketplaceData.duck';
import { fetchCurrentUserNotifications } from '../../ducks/user.duck';
@ -50,7 +51,6 @@ export default function checkoutPageReducer(state = initialState, action = {}) {
case ACCEPT_SALE_SUCCESS:
return { ...state, acceptInProgress: false };
case ACCEPT_SALE_ERROR:
console.error(payload); // eslint-disable-line
return { ...state, acceptInProgress: false, acceptSaleError: payload };
case REJECT_SALE_REQUEST:
@ -58,7 +58,6 @@ export default function checkoutPageReducer(state = initialState, action = {}) {
case REJECT_SALE_SUCCESS:
return { ...state, rejectInProgress: false };
case REJECT_SALE_ERROR:
console.error(payload); // eslint-disable-line
return { ...state, rejectInProgress: false, rejectSaleError: payload };
default:
@ -148,6 +147,7 @@ export const acceptSale = id =>
return response;
})
.catch(e => {
logError(e, { txId: id, transition: 'TRANSITION_ACCEPT' });
dispatch(acceptSaleError(e));
throw e;
});
@ -169,6 +169,7 @@ export const rejectSale = id =>
return response;
})
.catch(e => {
logError(e, { txId: id, transition: 'TRANSITION_REJECT' });
dispatch(rejectSaleError(e));
throw e;
});

View file

@ -2,6 +2,7 @@ import React, { Component, PropTypes } from 'react';
import { FormattedMessage, injectIntl, intlShape } from 'react-intl';
import classNames from 'classnames';
import { PrimaryButton } from '../../components';
import { error as logError } from '../../util/log';
import config from '../../config';
import css from './StripePaymentForm.css';
@ -141,8 +142,8 @@ class StripePaymentForm extends Component {
}
})
.catch(e => {
// eslint-disable-next-line no-console
console.error(e);
logError(e, { type: e.type, code: e.code, message: e.message });
this.setState({
submitting: false,
error: stripeErrorTranslation(intl, e),