1
0
mirror of https://github.com/deavmi/birchwood synced 2024-09-20 10:43:33 +02:00

Exceptions

- Added default auxillary information strings
- Use the default auxillary strings if the provided one is empty
This commit is contained in:
Tristan B. Velloza Kildaire 2023-03-19 15:59:43 +02:00
parent 1697331e00
commit fda11b5699

View File

@ -5,13 +5,29 @@ module birchwood.client.exceptions;
import std.conv : to;
/**
* Associated error strings which are used
* if a custom auxillary information is not
* passed in.
*
* TODO: Ensure each ErrorTYpe has a corresponding
* string here
*/
private string[] errorStrings = [
"The provided connection information is incorrect",
"Already connected to server",
"Connection to the server failed",
"The IRC params are empty",
"The provided channel name is invalid",
"The porvided nickname is invalid",
"The message contains illegal characters",
"The encoded IRC frame is too long to send"
];
/**
* The type of error to be used
* with BirchwoodException
*
* TODO: Make this STRING and associate a message with it
* but make it include the enum name and corresponding value
* when throwin an exception
*/
public enum ErrorType
{
@ -88,7 +104,7 @@ public class BirchwoodException : Exception
*/
this(ErrorType errType)
{
super("BirchwoodError("~to!(string)(errType)~")"~(auxInfo.length == 0 ? "" : " "~auxInfo));
super("BirchwoodError("~to!(string)(errType)~")"~(auxInfo.length == 0 ? errorStrings[errType] : " "~auxInfo));
this.errType = errType;
}