Skip to content

Commit

Permalink
Improved error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreylanters committed Jan 25, 2021
1 parent 8f8b6fc commit 52d2066
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Entity Component System

[![npm](https://img.shields.io/badge/upm-3.7.1-232c37.svg?style=for-the-badge)]()
[![npm](https://img.shields.io/badge/upm-3.7.2-232c37.svg?style=for-the-badge)]()
[![npm](https://img.shields.io/github/stars/elraccoone/unity-entity-component-system.svg?style=for-the-badge)]()
[![npm](https://img.shields.io/badge/build-passing-brightgreen.svg?style=for-the-badge)]()

Expand Down
12 changes: 6 additions & 6 deletions Runtime/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public virtual void OnUpdate () { }
// done during 'OnInitialize' cycle.
public void Register (params System.Type[] typesOf) {
if (this.isInitialized == true)
throw new System.Exception ("Unable to registered system outsize of OnInitialize cycle");
throw new System.Exception ("Cannot to registered System outsize of OnInitialize cycle");

for (var _typeOfIndex = 0; _typeOfIndex < typesOf.Length; _typeOfIndex++) {
var _instance = System.Activator.CreateInstance (typesOf[_typeOfIndex]);
Expand Down Expand Up @@ -183,15 +183,15 @@ public bool IsSystemEnabled<S> () {
for (var _systemIndex = 0; _systemIndex < this.systems.Count; _systemIndex++)
if (this.systems[_systemIndex].GetType () == _typeOfS)
return (S)this.systems[_systemIndex];
throw new System.Exception ("Unable to get system, it was not registerd to the controller");
throw new System.Exception ($"Unable to get System of type {_typeOfS}, it was not registerd to the Controller");
}

/// Gets a system from this controller.
public System.Object GetSystem (System.Type typeOf) {
for (var _systemIndex = 0; _systemIndex < this.systems.Count; _systemIndex++)
if (this.systems[_systemIndex].GetType () == typeOf)
return this.systems[_systemIndex];
throw new System.Exception ("Unable to get system, it was not registerd to the controller");
throw new System.Exception ($"Unable to get System of type {typeOf}, it was not registerd to the Controller");
}

/// Check whether this controller has a system.
Expand All @@ -209,15 +209,15 @@ public System.Object GetSystem (System.Type typeOf) {
for (var _serviceIndex = 0; _serviceIndex < this.services.Count; _serviceIndex++)
if (this.services[_serviceIndex].GetType () == _typeOfS)
return (S)this.services[_serviceIndex];
throw new System.Exception ("Unable to get service, it was not registerd to the controller");
throw new System.Exception ($"Unable to get Service of type {_typeOfS}, it was not registerd to the Controller");
}

/// Gets a system from this controller.
public System.Object GetService (System.Type typeOf) {
for (var _serviceIndex = 0; _serviceIndex < this.services.Count; _serviceIndex++)
if (this.services[_serviceIndex].GetType () == typeOf)
return this.services[_serviceIndex];
throw new System.Exception ("Unable to get service, it was not registerd to the controller");
throw new System.Exception ($"Unable to get Service of type {typeOf}, it was not registerd to the Controller");
}

/// Check whether this controller has a service.
Expand All @@ -234,7 +234,7 @@ public UnityEngine.Object GetAsset (string name) {
for (var _i = 0; _i < this.assets.Length; _i++)
if (this.assets[_i].name == name)
return this.assets[_i];
throw new System.Exception ($"Unable to get asset '{name}', it was not found on the controller");
throw new System.Exception ($"Unable to get Asset '{name}', it was not found on the Controller");
}

/// Gets an asset from this controller.
Expand Down
2 changes: 1 addition & 1 deletion Runtime/EntityComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private EntitySystemType GetSystem () {
if (this.system == null)
if (Controller.Instance.HasSystem<EntitySystemType> () == true)
this.system = Controller.Instance.GetSystem<EntitySystemType> ();
else throw new System.Exception ("Tried to access the system before it was registered");
else throw new System.Exception ("Tried to access the System before it was registered");
return this.system;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nl.elraccoone.entity-component-system",
"displayName": "Entity Component System",
"version": "3.7.1",
"version": "3.7.2",
"unity": "2019.1",
"description": "A better approach to game design that allows you to concentrate on the actual problems you are solving: the data and behavior that make up your game. By moving from object-oriented to data-oriented design it will be easier for you to reuse the code and easier for others to understand and work on it."
}

0 comments on commit 52d2066

Please sign in to comment.