Fix and log more unhandled errors.
- Logs errors that fall through to the App. - Logs unprocessed error in Saga. - Ensures ProfileApiService throws proper errors. - Fix LoggingService to pass through non-API errors. - Fix LoggingService to cap length of message. ARCH-427
This commit is contained in:
@@ -12,7 +12,6 @@ import { handleTrackEvents } from '../analytics/analytics';
|
||||
import { getLocale, getMessages } from '../i18n/i18n-loader';
|
||||
import SiteHeader from './common/SiteHeader';
|
||||
import ConnectedProfilePage from './ProfilePage';
|
||||
import LoggingService from '../services/LoggingService';
|
||||
|
||||
import FooterLogo from '../../assets/edx-footer.png';
|
||||
import NotFoundPage from './NotFoundPage';
|
||||
@@ -24,16 +23,6 @@ class App extends Component {
|
||||
this.props.fetchUserAccount(userAccountApiService, username);
|
||||
}
|
||||
|
||||
componentDidCatch(error, info) {
|
||||
let processedError = error;
|
||||
if (info) {
|
||||
processedError = Object.create(error);
|
||||
processedError.message = `${error.message} ${JSON.stringify(info)}`;
|
||||
}
|
||||
LoggingService.logAPIErrorResponse(processedError);
|
||||
// TODO: Handle user UX for uncaught errors
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<IntlProvider locale={getLocale()} messages={getMessages()}>
|
||||
|
||||
@@ -19,11 +19,13 @@ class LoggingService {
|
||||
|
||||
// Note: will simply log errors that don't seem to be API error responses.
|
||||
static logAPIErrorResponse(error) {
|
||||
let processedError = Object.create(error);
|
||||
let processedError;
|
||||
if (error.response) {
|
||||
processedError = new Error(`API request failed: ${error.response.status} ${error.response.config.url} ${JSON.stringify(error.response.data)}`);
|
||||
} else if (error.request) {
|
||||
processedError = new Error(`API request failed: ${error.request.status} ${error.request.responseURL} ${error.request.responseText}`);
|
||||
} else {
|
||||
processedError = Object.create(error);
|
||||
}
|
||||
if (processedError.message) {
|
||||
// NewRelic will not log the error if it is too long.
|
||||
|
||||
Reference in New Issue
Block a user