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