mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-28 12:43:11 +10:00
Add log.duck.js
Logging requests from duck files can now be dispatched to a logging thunk action that does not interrupt the application.
This commit is contained in:
parent
e35628660c
commit
3c4f20f2ad
4 changed files with 22 additions and 9 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { pick } from 'lodash';
|
||||
import { updatedEntities, denormalisedEntities } from '../../util/data';
|
||||
import * as propTypes from '../../util/propTypes';
|
||||
import * as log from '../../util/log';
|
||||
import { logError } from '../../ducks/log.duck';
|
||||
import { fetchCurrentUserHasOrdersSuccess } from '../../ducks/user.duck';
|
||||
|
||||
// ================ Action types ================ //
|
||||
|
|
@ -120,7 +120,7 @@ export const initiateOrder = params =>
|
|||
})
|
||||
.catch(e => {
|
||||
dispatch(initiateOrderError(e));
|
||||
log.error(e);
|
||||
dispatch(logError(e));
|
||||
throw e;
|
||||
});
|
||||
};
|
||||
|
|
@ -163,7 +163,7 @@ export const speculateTransaction = (listingId, bookingStart, bookingEnd) =>
|
|||
dispatch(speculateTransactionSuccess(tx));
|
||||
})
|
||||
.catch(e => {
|
||||
log.error(e);
|
||||
dispatch(logError(e));
|
||||
return dispatch(speculateTransactionError(e));
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { omit, omitBy, isUndefined } from 'lodash';
|
||||
import { types } from '../../util/sdkLoader';
|
||||
import * as log from '../../util/log';
|
||||
import { addMarketplaceEntities } from '../../ducks/marketplaceData.duck';
|
||||
import { logError } from '../../ducks/log.duck';
|
||||
import { fetchCurrentUserHasListingsSuccess } from '../../ducks/user.duck';
|
||||
|
||||
const requestAction = actionType => params => ({ type: actionType, payload: { params } });
|
||||
|
|
@ -280,7 +280,7 @@ export function requestCreateListing(data) {
|
|||
return response;
|
||||
})
|
||||
.catch(e => {
|
||||
log.error(e, { listingData: cleanedData });
|
||||
dispatch(logError(e, { listingData: cleanedData }));
|
||||
return dispatch(createListingError(e));
|
||||
});
|
||||
};
|
||||
|
|
@ -319,7 +319,7 @@ export function requestUpdateListing(tab, data) {
|
|||
dispatch(updateListingSuccess(updateResponse));
|
||||
})
|
||||
.catch(e => {
|
||||
log.error(e, { listingData: cleanedData });
|
||||
dispatch(logError(e, { listingData: cleanedData }));
|
||||
return dispatch(updateListingError(e));
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { types } from '../../util/sdkLoader';
|
||||
import * as propTypes from '../../util/propTypes';
|
||||
import * as log from '../../util/log';
|
||||
import { addMarketplaceEntities } from '../../ducks/marketplaceData.duck';
|
||||
import { fetchCurrentUserNotifications } from '../../ducks/user.duck';
|
||||
import { logError } from '../../ducks/log.duck';
|
||||
|
||||
// ================ Action types ================ //
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ export const acceptSale = id =>
|
|||
return response;
|
||||
})
|
||||
.catch(e => {
|
||||
log.error(e, { txId: id, transition: propTypes.TX_TRANSITION_ACCEPT });
|
||||
dispatch(logError(e, { txId: id, transition: propTypes.TX_TRANSITION_ACCEPT }));
|
||||
dispatch(acceptSaleError(e));
|
||||
throw e;
|
||||
});
|
||||
|
|
@ -166,7 +166,7 @@ export const rejectSale = id =>
|
|||
return response;
|
||||
})
|
||||
.catch(e => {
|
||||
log.error(e, { txId: id, transition: propTypes.TX_TRANSITION_REJECT });
|
||||
dispatch(logError(e, { txId: id, transition: propTypes.TX_TRANSITION_REJECT }));
|
||||
dispatch(rejectSaleError(e));
|
||||
throw e;
|
||||
});
|
||||
|
|
|
|||
13
src/ducks/log.duck.js
Normal file
13
src/ducks/log.duck.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* A utility duck file that can be used to log errors
|
||||
* asynchronously without interrupting other thunks.
|
||||
*/
|
||||
|
||||
import * as log from '../util/log';
|
||||
|
||||
// ================ Thunks ================ //
|
||||
|
||||
export const logError = (error, data) =>
|
||||
(dispatch, getState, sdk) => {
|
||||
log.error(error, data);
|
||||
};
|
||||
Loading…
Add table
Reference in a new issue