window.elexMvFormatResponseError = function(responseOrXhr, defaultMsg) {
	var errorMsg = defaultMsg || 'An error occurred. Please try again.';
	var response = responseOrXhr;

	if (responseOrXhr && typeof responseOrXhr.responseJSON !== 'undefined') {
		response = responseOrXhr.responseJSON;
	} else if (responseOrXhr && typeof responseOrXhr.responseText !== 'undefined') {
		return responseOrXhr.responseText;
	}

	if (response && response.data) {
		var data = response.data;
		if (typeof data === 'string') {
			errorMsg = data;
		} else if (typeof data === 'object' && data !== null) {
			errorMsg = Object.keys(data).map(function(key) {
				var val = data[key];
				return Array.isArray(val) ? val.join('<br>') : val;
			}).join('<br>');
		}
	} else if (typeof response === 'string') {
		errorMsg = response;
	}

	return errorMsg;
};

jQuery( document ).ready( function() {
	localStorage.removeItem( 'setup-page' );
} );
