mirror of
https://bitbucket.org/Mattrixwv/csclasses.git
synced 2025-12-06 18:23:58 -05:00
Added some exception handling
This commit is contained in:
@@ -123,9 +123,9 @@ namespace mee{
|
|||||||
goalNumber /= goalNumber;
|
goalNumber /= goalNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: If for some reason the goalNumber is not 1 throw an error
|
//If for some reason the goalNumber is not 1 throw an exception
|
||||||
if(goalNumber != 1){
|
if(goalNumber != 1){
|
||||||
|
throw new mee.Exceptions.InvalidResult("Factor did not end as 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Return the list of factors
|
//Return the list of factors
|
||||||
@@ -157,9 +157,9 @@ namespace mee{
|
|||||||
goalNumber /= goalNumber;
|
goalNumber /= goalNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: If for some reason the goalNumber is not 1 throw an error
|
//If for some reason the goalNumber is not 1 throw an exception
|
||||||
if(goalNumber != 1){
|
if(goalNumber != 1){
|
||||||
|
throw new mee.Exceptions.InvalidResult("Factor did not end as 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Return the list of factors
|
//Return the list of factors
|
||||||
@@ -191,9 +191,9 @@ namespace mee{
|
|||||||
goalNumber /= goalNumber;
|
goalNumber /= goalNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: If for some reason the goalNumber is not 1 throw an error
|
//If for some reason the goalNumber is not 1 throw an exception
|
||||||
if(goalNumber != 1){
|
if(goalNumber != 1){
|
||||||
|
throw new mee.Exceptions.InvalidResult("Factor did not end as 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Return the list of factors
|
//Return the list of factors
|
||||||
|
|||||||
13
CSClasses/Exceptions/InvalidResult.cs
Normal file
13
CSClasses/Exceptions/InvalidResult.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
namespace mee.Exceptions{
|
||||||
|
[System.Serializable]
|
||||||
|
public class InvalidResult : System.Exception{
|
||||||
|
public InvalidResult(){
|
||||||
|
}
|
||||||
|
public InvalidResult(string message) : base(message){
|
||||||
|
}
|
||||||
|
public InvalidResult(string message, System.Exception inner) : base(message, inner){
|
||||||
|
}
|
||||||
|
protected InvalidResult(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -106,7 +106,7 @@ namespace mee{
|
|||||||
case TIME_RESOLUTION.MINUTE: time += " minutes"; break;
|
case TIME_RESOLUTION.MINUTE: time += " minutes"; break;
|
||||||
case TIME_RESOLUTION.HOUR: time += " hours"; break;
|
case TIME_RESOLUTION.HOUR: time += " hours"; break;
|
||||||
case TIME_RESOLUTION.ERROR:
|
case TIME_RESOLUTION.ERROR:
|
||||||
default: time = "There was an error computing the time"; break; //TODO: This should throw an exception instead
|
default: throw new mee.Exceptions.InvalidResult("TIME_RESOLUTION was invalid");
|
||||||
}
|
}
|
||||||
//Return the string
|
//Return the string
|
||||||
return time;
|
return time;
|
||||||
|
|||||||
Reference in New Issue
Block a user