{"size": 740, "ext": "js", "max_stars_repo_path": "app/src/services/ErrorTranslator.js", "max_stars_repo_name": "rpatil524/mobilizing-million-hearts", "max_stars_repo_stars_event_min_datetime": "2020-11-23T21:10:00.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-21T22:54:52.000Z", "max_issues_repo_path": "app/src/services/ErrorTranslator.js", "max_issues_repo_name": "rpatil524/mobilizing-million-hearts", "max_issues_repo_issues_event_min_datetime": "2020-12-15T15:51:55.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-01T02:23:03.000Z", "max_forks_repo_path": "app/src/services/ErrorTranslator.js", "max_forks_repo_name": "rpatil524/mobilizing-million-hearts", "max_forks_repo_forks_event_min_datetime": "2021-03-10T16:36:56.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-10T16:36:56.000Z"}
{"max_stars_count": 9, "max_issues_count": 6, "max_forks_count": 1, "avg_line_length": 20.0, "max_line_length": 88, "alphanum_fraction": 0.6486486486}
const errors = [
	{
		label: 'Session expired. Please reload the application.',
		regex: /No 'state' parameter found/i,
	},
	{
		label: 'Invalid permissions. Please check your access to this patient and try again.',
		regex: /invalid_grant/i,
	},
	{
		label: 'The server did not respond. Please try again.',
		regex: /Gateway Timeout/i,
	},
	{
		label: 'An error has occured.',
		regex: /TypeError: Unable to get property/i,
	},
	{
		label: 'An error has occured.',
		regex: /SyntaxError: Invalid character/i,
	},
];

export default class ErrorTranslator {
	translate(error) {
		const found = errors.find(({ regex }) => {
			return regex.test(error);
		});

		if (found) {
			return found.label;
		}

		return 'An error has occured.';
	}
}
