* WIP Global error handler Adding components Adding actions * Add general errors where errors are caught * Filter out non displayable errors * Initial setup to email errors * Add current user/team to error email * Fix a few lints * Ensure errors are cleared when reporting a problem * Add clear all and internationalization * Fix trailing comma issue * fix lints * Use Formatted Text component * Move error list out of channel * Add mobile prefix to i18n id for connection error * Set shouldRender to true in RightMenuDrawerItem.defaultProps * Update component name for RightMenuDrawerItem * Clean up propTypes in RightMenuDrawerItem * Clean up styles in RightMenuDrawerItem * Use selector to filter displayable errors * Clarify code for constructing wrapper style in ErrorList * Avoid indenting email body for error report * Remove extraneous params from errors actions * Rename action type for logging errors * Rename action for logging errors * Set shouldRender to true in RightMenuDrawerItem.defaultProps * Make logged errors displayable by default * Don't log error when websocket connection is closed * Hide button to dismiss all errors if ShowErrorsList isn't enabled * Display only last error in alert bar when ShowErrorsList is disabled * Add error logging where missing in actions * Always show button to report problem * Only include errors in report problem email if any have been logged * Clarify subject of report problem email * Set ShowErrorsList to false in default config.json * Remove unused component + translation for connection errors * Capture entire error object not just message * Display fallback if error.message is blank * Log errors in login actions * Fix construction of errors email body
27 lines
671 B
JavaScript
27 lines
671 B
JavaScript
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
import {ErrorTypes} from 'service/constants';
|
|
|
|
export default (state = [], action) => {
|
|
switch (action.type) {
|
|
case ErrorTypes.DISMISS_ERROR: {
|
|
const nextState = [...state];
|
|
nextState.splice(action.index, 1);
|
|
|
|
return nextState;
|
|
}
|
|
case ErrorTypes.LOG_ERROR: {
|
|
const nextState = [...state];
|
|
const {displayable, error} = action;
|
|
nextState.push({displayable, error});
|
|
|
|
return nextState;
|
|
}
|
|
case ErrorTypes.CLEAR_ERRORS: {
|
|
return [];
|
|
}
|
|
default:
|
|
return state;
|
|
}
|
|
};
|