# -*- coding: utf-8 -*-

_Onedrive_codes = {
	200:	('The request was successful.',),
	201:	('The resource was created.',),
	204:	('The resource was deleted or no comments found.',),
	225:	('The request was successful. This is an existing file.',),
	230:	('The request was successful, This an empty directory.',),
	235:	('The request was successful. This is NOT an empty directory',),
	302:	('The response is a redirect to a specific location.',),
	400:	('Bad request or error. See the response error message for more details.',),
	401:	('The token was invalid, missing, or expired.',),
	403:	('The token was not authorized, or the user has not been granted permissions.',),
	404:	('The resource was not found.',),
	405:	('An invalid method was used.',),
	406: 	('Not_acceptable or write possible or forbidden.',),
	408:	('The request timed out.',),
	409:	('The request failed, due to an edit conflict or destination already exists',),
	410:	('The endpoint or scenario is no longer supported.',),
	413:	('The request entity body was too large or not enough space.',),
	415:	('The request entity body was an invalid media type.',),
	417: 	('Error during writing, expectation_failed',),
	420:	('The request was throttled. Throttling occurs on a per/app and per/user basis.',),
	423:	('The requested resource is locked and can\'t be updated.',),
	428: 	('precondition_required',),
	499:	('There is a connection issue with the client.',),
	500:	('The server had an unexpected error.',),
	503:	('The server is unavailable.',),
	507:	('The user doesn\'t have enough available storage.',),
}

# Obtain  message based on statuscode
"""
Return string with error message. If code is not in list it will return the optional returnmessage (default = None)
"""
def get_error_message(stcode,default="None"):
	for (code, titles) in _Onedrive_codes.items():
		if code == stcode: 
			for title in titles:
				return(title)
	return(default)
