Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception handling improvements #28

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions source/birchwood/client/exceptions.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -94,7 +110,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;
}

Expand All @@ -108,8 +124,8 @@ public class BirchwoodException : Exception
*/
this(ErrorType errType, string auxInfo)
{
this(errType);
this.auxInfo = auxInfo;
this(errType);
}

/**
Expand Down