forked from Tunaki/chatexchange
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
92 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/org/sobotics/chatexchange/chat/ChatLoginException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.sobotics.chatexchange.chat; | ||
|
||
/** | ||
* Exception when the login fails. Contains information about the hosts | ||
* | ||
* @author FelixSFD | ||
*/ | ||
public class ChatLoginException extends Exception { | ||
private static final long serialVersionUID = 3836431112726533617L; | ||
|
||
/** | ||
* {@link ChatHost} that was used for the login | ||
*/ | ||
private ChatHost host; | ||
|
||
/** | ||
* Initializes the exception | ||
* @param chatHost {@link ChatHost} that was used for the login | ||
* @param message Error-message | ||
*/ | ||
public ChatLoginException(ChatHost chatHost, String message) { | ||
super(message); | ||
this.host = chatHost; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public String getMessage() { | ||
String msg = "Unable to login to " + this.host.getName(); | ||
|
||
if (!this.host.getName().equalsIgnoreCase(this.host.getLoginHost())) { | ||
msg += " (via " + this.host.getLoginHost() + ")"; | ||
} | ||
|
||
msg += ": " + super.getMessage(); | ||
|
||
return msg; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public String getLocalizedMessage() { | ||
return this.getMessage(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters