hino / app / services / errors.js
errors.js
Raw
import Service  from '@ember/service';
import { inject as service }  from '@ember/service';

export default Service.extend({
	router : service(),
	init() {
		this._super(...arguments); 
	},
	getErrorMessages(e) {
		console.log(e);
		let errorMessages = new Array();
		if(e && e.errors) {
			if (Array.isArray(e.errors)) {
				e.errors.forEach(function(item) {
					if (item.detail) {
						//ini di minta jadi you don't have access to this menu, please contact your administrator
						if(item.detail == "Method Not Allowed."){
							errorMessages.push("you don't have access to this menu, please contact your administrator");	
						}else{
							errorMessages.push(item.detail);
						}
						
					}
				});
			}
		} else if (e.message) {
			if(e.message == "Method Not Allowed."){
				errorMessages.push("you don't have access to this menu, please contact your administrator");	
			}else{
				errorMessages.push(e.message);
				}
		
		} else {
			if(e.status == "Method Not Allowed."){
				errorMessages.push("you don't have access to this menu, please contact your administrator");	
			}else{
			errorMessages.push(e.status);
			}
		}
		return errorMessages;
	},
});