more helpful ID lookup error messages
							parent
							
								
									0a2cc2527a
								
							
						
					
					
						commit
						fa6958ed95
					
				|  | @ -167,17 +167,38 @@ namespace Encompass | |||
| 
 | ||||
|         internal IComponent GetComponentByID(Guid componentID) | ||||
|         { | ||||
|             return IDToComponent[componentID]; | ||||
|             if (IDToComponent.ContainsKey(componentID)) | ||||
|             { | ||||
|                 return IDToComponent[componentID]; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 throw new ComponentNotFoundException("Component with ID {0} does not exist.", componentID); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         internal Type GetComponentTypeByID(Guid componentID) | ||||
|         { | ||||
|             return componentIDToType[componentID]; | ||||
|             if (componentIDToType.ContainsKey(componentID)) | ||||
|             { | ||||
|                 return componentIDToType[componentID]; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 throw new ComponentNotFoundException("Component with ID {0} does not exist.", componentID); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         internal Guid GetEntityIDByComponentID(Guid componentID) | ||||
|         { | ||||
|             return componentIDToEntityID[componentID]; | ||||
|             if (componentIDToEntityID.ContainsKey(componentID)) | ||||
|             { | ||||
|                 return componentIDToEntityID[componentID]; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 throw new ComponentNotFoundException("Component with ID {0} does not exist.", componentID); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         internal void MarkAllComponentsOnEntityForRemoval(Guid entityID) | ||||
|  |  | |||
|  | @ -277,17 +277,38 @@ namespace Encompass | |||
| 
 | ||||
|         internal IComponent GetComponentByID(Guid componentID) | ||||
|         { | ||||
|             return componentIDToComponent[componentID]; | ||||
|             if (componentIDToComponent.ContainsKey(componentID)) | ||||
|             { | ||||
|                 return componentIDToComponent[componentID]; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 throw new ComponentNotFoundException("Component with ID {0} does not exist.", componentID); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         internal Type GetComponentTypeByID(Guid componentID) | ||||
|         { | ||||
|             return componentIDToType[componentID]; | ||||
|             if (componentIDToType.ContainsKey(componentID)) | ||||
|             { | ||||
|                 return componentIDToType[componentID]; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 throw new ComponentNotFoundException("Component with ID {0} does not exist.", componentID); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         internal Guid GetEntityIDByComponentID(Guid componentID) | ||||
|         { | ||||
|             return componentIDToEntityID[componentID]; | ||||
|             if (componentIDToEntityID.ContainsKey(componentID)) | ||||
|             { | ||||
|                 return componentIDToEntityID[componentID]; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 throw new ComponentNotFoundException("Component with ID {0} does not exist.", componentID); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -1,5 +1,7 @@ | |||
| using System.Linq; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using Encompass.Exceptions; | ||||
| 
 | ||||
| namespace Encompass | ||||
| { | ||||
|  | @ -35,7 +37,14 @@ namespace Encompass | |||
| 
 | ||||
|         public Entity GetEntity(Guid id) | ||||
|         { | ||||
|             return IDToEntity[id]; | ||||
|             if (IDToEntity.ContainsKey(id)) | ||||
|             { | ||||
|                 return IDToEntity[id]; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 throw new EntityNotFoundException("Entity with ID {0} does not exist.", id); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         public void MarkForDestroy(Guid entityID) | ||||
|  |  | |||
|  | @ -0,0 +1,12 @@ | |||
| using System; | ||||
| 
 | ||||
| namespace Encompass.Exceptions | ||||
| { | ||||
|     public class ComponentNotFoundException : Exception | ||||
|     { | ||||
|         public ComponentNotFoundException( | ||||
|             string format, | ||||
|             params object[] args | ||||
|         ) : base(string.Format(format, args)) { } | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,12 @@ | |||
| using System; | ||||
| 
 | ||||
| namespace Encompass.Exceptions | ||||
| { | ||||
|     public class EntityNotFoundException : Exception | ||||
|     { | ||||
|         public EntityNotFoundException( | ||||
|             string format, | ||||
|             params object[] args | ||||
|         ) : base(string.Format(format, args)) { } | ||||
|     } | ||||
| } | ||||
		Loading…
	
		Reference in New Issue