mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-04-29 22:27:33 +00:00
[Change] Framework-API 调整 NoFoundSenderException 类名, 并添加可提供消息的构造器;
[Change] NoFoundSenderException -> NotFoundSenderException 更改类名; [Change] NotFoundSenderException 添加可提供消息的构造器; [Change] SenderFactory 适配更改;
This commit is contained in:
parent
f945b52fa4
commit
756df33442
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package net.lamgc.cgj.bot.framework;
|
package net.lamgc.cgj.bot.framework;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import net.lamgc.cgj.bot.framework.message.MessageSource;
|
import net.lamgc.cgj.bot.framework.message.MessageSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,7 +25,7 @@ import net.lamgc.cgj.bot.framework.message.MessageSource;
|
|||||||
* <p> 当 {@link SenderFactory} 无法通过传入的 {@link MessageSource} 和 Id 找到对应消息源时, 将抛出本异常.
|
* <p> 当 {@link SenderFactory} 无法通过传入的 {@link MessageSource} 和 Id 找到对应消息源时, 将抛出本异常.
|
||||||
* @see SenderFactory
|
* @see SenderFactory
|
||||||
*/
|
*/
|
||||||
public class NoFoundSenderException extends RuntimeException {
|
public class NotFoundSenderException extends RuntimeException {
|
||||||
|
|
||||||
private final MessageSource source;
|
private final MessageSource source;
|
||||||
private final long id;
|
private final long id;
|
||||||
@ -34,8 +35,19 @@ public class NoFoundSenderException extends RuntimeException {
|
|||||||
* @param source 传入的消息源类型.
|
* @param source 传入的消息源类型.
|
||||||
* @param id 传入的消息源 Id.
|
* @param id 传入的消息源 Id.
|
||||||
*/
|
*/
|
||||||
public NoFoundSenderException(MessageSource source, long id) {
|
public NotFoundSenderException(MessageSource source, long id) {
|
||||||
super("Source Type: " + source + ", id: " + id);
|
this(source, id, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造异常.
|
||||||
|
* @param source 传入的消息源类型.
|
||||||
|
* @param id 传入的消息源 Id.
|
||||||
|
*/
|
||||||
|
public NotFoundSenderException(MessageSource source, long id, String message) {
|
||||||
|
super(Strings.isNullOrEmpty(message) ?
|
||||||
|
"Source Type: " + source + ", id: " + id :
|
||||||
|
message + " (" + "Source Type: " + source + ", id: " + id + ")");
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
@ -39,8 +39,8 @@ public interface SenderFactory extends ExtensionPoint {
|
|||||||
* @param source 消息源类型.
|
* @param source 消息源类型.
|
||||||
* @param id 消息源 Id.
|
* @param id 消息源 Id.
|
||||||
* @return 返回消息发送器, 本方法不允许返回 null.
|
* @return 返回消息发送器, 本方法不允许返回 null.
|
||||||
* @throws NoFoundSenderException 当无法获取对应的消息源发送器时, 将抛出该异常.
|
* @throws NotFoundSenderException 当无法获取对应的消息源发送器时, 将抛出该异常.
|
||||||
*/
|
*/
|
||||||
MessageSender getSender(MessageSource source, long id) throws NoFoundSenderException;
|
MessageSender getSender(MessageSource source, long id) throws NotFoundSenderException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user