src/ai/api/ai_error.cpp
branchnoai
changeset 9861 53fc03195e31
parent 9849 edf90dda4ec4
child 9863 73647fe2e301
equal deleted inserted replaced
9860:4f554e7b1985 9861:53fc03195e31
    17 	return (*it).second;
    17 	return (*it).second;
    18 }
    18 }
    19 
    19 
    20 /* static */ const char *AIError::GetLastErrorString()
    20 /* static */ const char *AIError::GetLastErrorString()
    21 {
    21 {
    22 	if (AIObject::GetLastError() == STR_NULL) return strdup("ERR_NONE");
    22 	return (*error_map_string.find(AIError::GetLastError())).second;
    23 
       
    24 	AIErrorMapString::iterator it = error_map_string.find(AIObject::GetLastError());
       
    25 	if (it == error_map_string.end()) return strdup("ERR_UNKNOWN");
       
    26 	return (*it).second;
       
    27 }
    23 }
    28 
    24 
    29 /* static */ void AIError::RegisterErrorMap(uint internal_string_id, uint ai_error_msg)
    25 /* static */ void AIError::RegisterErrorMap(uint internal_string_id, uint ai_error_msg)
    30 {
    26 {
    31 	error_map[internal_string_id] = ai_error_msg;
    27 	error_map[internal_string_id] = ai_error_msg;
    32 }
    28 }
    33 
    29 
    34 /* static */ void AIError::RegisterErrorMapString(uint internal_string_id, const char *message)
    30 /* static */ void AIError::RegisterErrorMapString(uint ai_error_msg, const char *message)
    35 {
    31 {
    36 	error_map_string[internal_string_id] = message;
    32 	error_map_string[ai_error_msg] = message;
    37 }
    33 }
    38 
    34 
    39 /* static */ AIError::ErrorCategories AIError::GetErrorCategory() {
    35 /* static */ AIError::ErrorCategories AIError::GetErrorCategory() {
    40 	return (AIError::ErrorCategories)(GetLastError() >> (uint)ERR_CAT_BIT_SIZE);
    36 	return (AIError::ErrorCategories)(GetLastError() >> (uint)ERR_CAT_BIT_SIZE);
    41 }
    37 }