export default {
    state: {
        errorCount: 0,
        errorRepresentation: null,
    },
    getters: {
        getErrorRepresentation(state) {
            return state.errorRepresentation;
        },
        getErrorCount(state) {
            return state.errorCount;
        }
    },
    mutations: {
        setErrorMessage(state, { error }) {
            state.errorRepresentation = error;
            state.errorCount += 1;
        },
    },
    actions: {
        setErrorMessage(context, errorMessage) {
            debugger;

            if (errorMessage.error.ignoreUnhandledRejection) {
                return
            }
            context.commit('setErrorMessage', { error: errorMessage.error });
            console.error(`Displaying error message for:\n`, errorMessage);
            // throw { source: errorMessage, ignoreUnhandledRejection: true };
        },
    }
}