{"size": 3947, "ext": "js", "max_stars_repo_path": "client/src/reducers/errorReducer/errorReducer.js", "max_stars_repo_name": "sigma3Dev/sigma3DSolutions", "max_stars_repo_stars_event_min_datetime": "2018-03-07T14:36:28.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-06T15:58:21.000Z", "max_issues_repo_path": "client/src/reducers/errorReducer/errorReducer.js", "max_issues_repo_name": "sigma3Dev/sigma3DSolutions", "max_issues_repo_issues_event_min_datetime": "2018-03-06T08:28:58.000Z", "max_issues_repo_issues_event_max_datetime": "2018-05-24T08:59:30.000Z", "max_forks_repo_path": "client/src/reducers/errorReducer/errorReducer.js", "max_forks_repo_name": "sigma3Dev/sigma3DSolutions", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 4, "max_issues_count": 77, "max_forks_count": null, "avg_line_length": 36.5462962963, "max_line_length": 144, "alphanum_fraction": 0.7050924753}
import { REMOVE_ERROR } from '../../actions/errorHandling/errorHandlingActions';
import { SUBMIT_3D_TRAFO_COORDS_FAILURE } from '../../actions/submitThreeDTrafoCoords/submitThreeDTrafoCoordsActions';
import { SUBMIT_FIT_CIRCLE_CHEBYSHEV_COORDS_FAILURE } from '../../actions/submitFitCircleChebyshevCoords/submitFitCircleChebyshevCoordsActions';
import { SUBMIT_PARAM_INVERSION_COORDS_FAILURE } from '../../actions/paramInversionCoords/paramInversionCoordsActions';
import { SUBMIT_APPLY_TRAFO_VALUES_FAILURE } from '../../actions/submitApplyTransformationValues/submitApplyTransformationValuesActions';
import { SUBMIT_QUAT_TO_CARDAN_COORDS_FAILURE } from '../../actions/quatCardanCoords/quatCardanCoordsActions';
import { SUBMIT_FIT_PLANE_GAUSS_COORDS_FAILURE } from '../../actions/submitFitPlaneGaussCoords/submitFitPlaneGaussCoordsActions';
import { SUBMIT_FIT_PLANE_RANSAC_COORDS_FAILURE } from '../../actions/submitFitPlaneRansacCoords/submitFitPlaneRansacCoordsActions';
import { SUBMIT_FIT_CYLINDER_COORDS_FAILURE } from '../../actions/submitFitCylinderCoords/submitFitCylinderCoordsActions';
import { SUBMIT_FIT_POINT_COORDS_FAILURE } from '../../actions/submitFitPointCoords/submitFitPointCoordsActions';
import { SUBMIT_FIT_LINE_L_TWO_COORDS_FAILURE } from '../../actions/submitFitLineL2Coords/submitFitLineL2CoordsActions';
import { SUBMIT_FIT_LINE_RANSAC_COORDS_FAILURE } from '../../actions/submitFitLineRansacCoords/submitFitLineRansacCoordsActions';
import { SUBMIT_FIT_CIRCLE_L_TWO_COORDS_FAILURE } from '../../actions/submitFitCircleL2Coords/submitFitCircleL2CoordsActions';
import { SUBMIT_FIT_SPHERE_COORDS_FAILURE } from '../../actions/submitFitSphereCoords/submitFitSphereCoordsActions';
import { SUBMIT_BUNDLE_ADJUSTMENT_COORDS_FAILURE } from '../../actions/submitBundleAdjustmentCoords/submitBundleAdjustmentCoordsActions';

const initialErrorState = { error: null };

/**
 * Handles errors
 * @param {Object} state - current error state
 * @param {Object} action - action to be executed
 * @returns {Object} state - updated state
 */
function errorHandling(state = initialErrorState, action) {
  switch (action.type) {
    case REMOVE_ERROR:
      return {
        ...state,
        error: null,
      };
    case SUBMIT_3D_TRAFO_COORDS_FAILURE:
      return {
        ...state,
        error: action.error,
      };
    case SUBMIT_FIT_CIRCLE_CHEBYSHEV_COORDS_FAILURE:
      return {
        ...state,
        error: action.error,
      };
    case SUBMIT_PARAM_INVERSION_COORDS_FAILURE:
      return {
        ...state,
        error: action.error,
      };
    case SUBMIT_APPLY_TRAFO_VALUES_FAILURE:
      return {
        ...state,
        error: action.error,
      };
    case SUBMIT_QUAT_TO_CARDAN_COORDS_FAILURE:
      return {
        ...state,
        error: action.error,
      };
    case SUBMIT_FIT_PLANE_GAUSS_COORDS_FAILURE:
      return {
        ...state,
        error: action.error,
      };
    case SUBMIT_FIT_PLANE_RANSAC_COORDS_FAILURE:
      return {
        ...state,
        error: action.error,
      };
    case SUBMIT_FIT_CYLINDER_COORDS_FAILURE:
      return {
        ...state,
        error: action.error,
      };
    case SUBMIT_FIT_POINT_COORDS_FAILURE:
      return {
        ...state,
        error: action.error,
      };
    case SUBMIT_FIT_LINE_L_TWO_COORDS_FAILURE:
      return {
        ...state,
        error: action.error,
      };
    case SUBMIT_FIT_LINE_RANSAC_COORDS_FAILURE:
      return {
        ...state,
        error: action.error,
      };
    case SUBMIT_FIT_CIRCLE_L_TWO_COORDS_FAILURE:
      return {
        ...state,
        error: action.error,
      };
    case SUBMIT_FIT_SPHERE_COORDS_FAILURE:
      return {
        ...state,
        error: action.error,
      };
    case SUBMIT_BUNDLE_ADJUSTMENT_COORDS_FAILURE:
      return {
        ...state,
        error: action.error,
      };
    default:
      return state;
  }
}

export default errorHandling;
