Changed message to debugMessage, trimmed constructors.
This commit is contained in:
parent
0d716b0bb3
commit
59869fcdc3
3 changed files with 33 additions and 32 deletions
|
@ -141,9 +141,9 @@ public final class CurrencyConverter extends AbstractModule {
|
|||
.substring(1)
|
||||
+ ' '
|
||||
+ cmds[3].toUpperCase());
|
||||
} catch (NullPointerException ignored) {
|
||||
return new ErrorMessage(
|
||||
"The supported currencies are: " + EXCHANGE_RATES.keySet().toString());
|
||||
} catch (Exception e) {
|
||||
throw new ModuleException("convertCurrency(" + query + ')',
|
||||
"The supported currencies are: " + EXCHANGE_RATES.keySet().toString(), e);
|
||||
}
|
||||
}
|
||||
} else if (query.equals(CURRENCY_RATES_KEYWORD)) {
|
||||
|
@ -207,7 +207,7 @@ public final class CurrencyConverter extends AbstractModule {
|
|||
}
|
||||
bot.send(msg.isPrivate() ? sender : bot.getChannel(), msg.getMessage());
|
||||
} catch (ModuleException e) {
|
||||
bot.getLogger().debug(e.getMessage(), e);
|
||||
bot.getLogger().warn(e.getDebugMessage(), e);
|
||||
bot.send(sender, e.getMessage());
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -122,7 +122,7 @@ public final class Joke extends AbstractModule {
|
|||
try {
|
||||
randomJoke();
|
||||
} catch (ModuleException e) {
|
||||
bot.getLogger().warn(e.getMessage(), e);
|
||||
bot.getLogger().warn(e.getDebugMessage(), e);
|
||||
bot.send(sender, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,44 +32,45 @@
|
|||
package net.thauvin.erik.mobibot.modules;
|
||||
|
||||
/**
|
||||
* The <code>ModuleExcepetion</code> class.
|
||||
* The <code>ModuleException</code> class.
|
||||
*
|
||||
* @author <a href="https://erik.thauvin.net/" target="_blank">Erik C. Thauvin</a>
|
||||
* @created 2019-04-07
|
||||
* @since 1.0
|
||||
*/
|
||||
public class ModuleException extends Exception {
|
||||
class ModuleException extends Exception {
|
||||
private static final long serialVersionUID = -3036774290621088107L;
|
||||
private final String debugMessage;
|
||||
|
||||
private final String query;
|
||||
|
||||
ModuleException(String query, String message) {
|
||||
super(message);
|
||||
this.query = query;
|
||||
|
||||
}
|
||||
|
||||
ModuleException(String query, Throwable cause) {
|
||||
super(cause);
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
ModuleException(String query, String message, Throwable cause) {
|
||||
/**
|
||||
* Creates a new exception.
|
||||
*
|
||||
* @param debugMessage The debug message.
|
||||
* @param message The exception message.
|
||||
* @param cause The cause.
|
||||
*/
|
||||
ModuleException(String debugMessage, String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.query = query;
|
||||
this.debugMessage = debugMessage;
|
||||
}
|
||||
|
||||
ModuleException(String message) {
|
||||
/**
|
||||
* Creates a new exception.
|
||||
*
|
||||
* @param debugMessage The debug message.
|
||||
* @param message The exception message.
|
||||
*/
|
||||
ModuleException(String debugMessage, String message) {
|
||||
super(message);
|
||||
query = "";
|
||||
this.debugMessage = debugMessage;
|
||||
}
|
||||
|
||||
ModuleException(Throwable cause) {
|
||||
super(cause);
|
||||
query = "";
|
||||
}
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
/**
|
||||
* Returns the debug message.
|
||||
*
|
||||
* @return The debug message.
|
||||
*/
|
||||
String getDebugMessage() {
|
||||
return debugMessage;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue