mirror of
https://github.com/deavmi/birchwood
synced 2024-09-20 13:43:19 +02:00
Client
- Pass in custom error messages for clarity
This commit is contained in:
parent
3aa14492e2
commit
d2b4ccfeda
@ -231,12 +231,12 @@ public class Client : Thread
|
|||||||
/* If not */
|
/* If not */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.NICKNAME_TOO_LONG);
|
throw new BirchwoodException(ErrorType.NICKNAME_TOO_LONG, "The nickname was over thge length of "~to!(string)(maxNickLen)~" characters");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS);
|
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS, "There are illegal characters in the nickname");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,12 +262,12 @@ public class Client : Thread
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.INVALID_CHANNEL_NAME);
|
throw new BirchwoodException(ErrorType.INVALID_CHANNEL_NAME, "Channel name does not start with a #");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS);
|
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS, "Invalid characters in channel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,7 +321,7 @@ public class Client : Thread
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS);
|
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS, "Invalid characters in the channel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,13 +331,13 @@ public class Client : Thread
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS);
|
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS, "Invalid characters in the channel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* If no channels provided at all (error) */
|
/* If no channels provided at all (error) */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.EMPTY_PARAMS);
|
throw new BirchwoodException(ErrorType.EMPTY_PARAMS, "No channels provided");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,7 +393,7 @@ public class Client : Thread
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS);
|
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS, "Invalid characters in the channel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,13 +403,13 @@ public class Client : Thread
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS);
|
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS, "Invalid characters in the channel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* If no channels provided at all (error) */
|
/* If no channels provided at all (error) */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.EMPTY_PARAMS);
|
throw new BirchwoodException(ErrorType.EMPTY_PARAMS, "No channels were provided");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,7 +434,7 @@ public class Client : Thread
|
|||||||
/* If invalid characters were present */
|
/* If invalid characters were present */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS);
|
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS, "There are illegal characters in the channel name");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,7 +488,7 @@ public class Client : Thread
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS);
|
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS, "There are illegal characters in the recipient");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -498,18 +498,18 @@ public class Client : Thread
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS);
|
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS, "There are illegal characters in the recipient");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS);
|
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS, "The message contains invalid characters");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* If no recipients provided at all (error) */
|
/* If no recipients provided at all (error) */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.EMPTY_PARAMS);
|
throw new BirchwoodException(ErrorType.EMPTY_PARAMS, "No recipients were provided");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,8 +525,6 @@ public class Client : Thread
|
|||||||
*/
|
*/
|
||||||
public void directMessage(string message, string recipient)
|
public void directMessage(string message, string recipient)
|
||||||
{
|
{
|
||||||
//TODO: Add check on recipient
|
|
||||||
|
|
||||||
/* Ensure the message and recipient are valid text */
|
/* Ensure the message and recipient are valid text */
|
||||||
if(isValidText(message) && isValidText(recipient))
|
if(isValidText(message) && isValidText(recipient))
|
||||||
{
|
{
|
||||||
@ -539,12 +537,12 @@ public class Client : Thread
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.INVALID_NICK_NAME);
|
throw new BirchwoodException(ErrorType.INVALID_NICK_NAME, "The provided nickname contains invalid characters");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS);
|
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS, "There are illegal characters in either the message of the recipient");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,7 +595,7 @@ public class Client : Thread
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS);
|
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS, "One of the channel names contains invalid characters");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,18 +605,18 @@ public class Client : Thread
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS);
|
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS, "One of the channel names contains invalid characters");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS);
|
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS, "Invalid characters in the message");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* If no channels provided at all (error) */
|
/* If no channels provided at all (error) */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.EMPTY_PARAMS);
|
throw new BirchwoodException(ErrorType.EMPTY_PARAMS, "No channels were provided");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,12 +644,12 @@ public class Client : Thread
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.INVALID_CHANNEL_NAME);
|
throw new BirchwoodException(ErrorType.INVALID_CHANNEL_NAME, "The channel is missign a # infront of its name");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS);
|
throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS, "Channel name of message contains invalid characters");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -927,7 +925,7 @@ public class Client : Thread
|
|||||||
/* If above then throw an exception */
|
/* If above then throw an exception */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new BirchwoodException(ErrorType.COMMAND_TOO_LONG);
|
throw new BirchwoodException(ErrorType.COMMAND_TOO_LONG, "The final encoded length of the message is too long");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user