mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-27 09:13:14 +10:00
Merge pull request #1071 from sharetribe/improve-api-error-printing
Improve printing API errors
This commit is contained in:
commit
bce7c8f486
2 changed files with 15 additions and 2 deletions
|
|
@ -14,6 +14,8 @@ way to update this template, but currently, we follow a pattern:
|
|||
|
||||
## Upcoming version 2019-XX-XX
|
||||
|
||||
- [add] Improve printing API errors on web inspector (console.table)
|
||||
[#1070](https://github.com/sharetribe/flex-template-web/pull/1070)
|
||||
- [fix] ManageAvailabilityCalendar.js didn't use UTC time when fetching data for calendar months.
|
||||
[#1069](https://github.com/sharetribe/flex-template-web/pull/1069)
|
||||
- [add] Use sparse fields on InboxPage query to reduce data load.
|
||||
|
|
|
|||
|
|
@ -47,6 +47,13 @@ export const clearUserId = () => {
|
|||
});
|
||||
};
|
||||
|
||||
const printAPIErrorsAsConsoleTable = apiErrors => {
|
||||
if (typeof console.table === 'function') {
|
||||
console.log('Errors returned by Marketplace API call:');
|
||||
console.table(apiErrors.map(err => ({ status: err.status, code: err.code, ...err.meta })));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Logs an execption. If Sentry is configured
|
||||
* sends the error information there. Otherwise
|
||||
|
|
@ -57,8 +64,9 @@ export const clearUserId = () => {
|
|||
* @param {Object} data Additional data to be sent to Sentry
|
||||
*/
|
||||
export const error = (e, code, data) => {
|
||||
const apiErrors = responseApiErrorInfo(e);
|
||||
if (config.sentryDsn) {
|
||||
const extra = { ...data, apiErrorData: responseApiErrorInfo(e) };
|
||||
const extra = { ...data, apiErrorData: apiErrors };
|
||||
|
||||
Sentry.withScope(scope => {
|
||||
scope.setTag('code', code);
|
||||
|
|
@ -67,8 +75,11 @@ export const error = (e, code, data) => {
|
|||
});
|
||||
Sentry.captureException(e);
|
||||
});
|
||||
|
||||
printAPIErrorsAsConsoleTable(apiErrors);
|
||||
} else {
|
||||
console.error(e); // eslint-disable-line
|
||||
console.error(e);
|
||||
console.error('Error code:', code, 'data:', data);
|
||||
printAPIErrorsAsConsoleTable(apiErrors);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue