MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

    【mirai-core】希望把登录过程中和事件监听中产生的异常直接抛出来

    BUG反馈
    2
    2
    52
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • 2
      2446694 last edited by

      使用模块:mirai-core

      希望把登录过程中(Bot.login)和事件监听中(Listener)产生的异常直接抛出来
      如果异常在内部发生了异常直接在内部处理了,外部不好判断内部具体的错误原因。

      如果把异常抛出,可以方便在开发过程中处理是那种异常导致是什么类型,从而可以做出不同的处理。

      如果你不想改变之前的代码,希望可以新增一个可以处理异常的方法
      如:
      Bot.login 还是原来不抛异常的方法
      Bot.loginAndThrow 是可以抛出异常的方法
      监听事件异常也类似

      1 Reply Last reply Reply Quote 0
      • MrXiaoM
        MrXiaoM 童心未泯 last edited by

        登录的话你可以封装个 try catch,mirai-console 的登录命令都是这么做的。
        事件监听的话,你添加个 exceptionHandler 就好了。

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact