mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-25 12:37:39 +08:00
add err handler for UpdateListener
- add err handler for UpdateListener in MornyCoeur - for network-related exception, will only output exception basic message and not report. - for other type of exception, will output all message of exception and do report. - Scheduler's runnerName now is `$classBaseName@$hashCode`
This commit is contained in:
parent
2c30b5ec09
commit
720771719e
@ -5,12 +5,12 @@ MORNY_ARCHIVE_NAME = morny-coeur
|
||||
MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono
|
||||
MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s
|
||||
|
||||
VERSION = 1.3.0-dev3
|
||||
VERSION = 1.3.0-dev4
|
||||
|
||||
USE_DELTA = false
|
||||
VERSION_DELTA =
|
||||
|
||||
CODENAME = xiongan
|
||||
CODENAME = guanggu
|
||||
|
||||
# dependencies
|
||||
|
||||
|
@ -96,7 +96,42 @@ class MornyCoeur (using val config: MornyConfig) {
|
||||
|
||||
daemons.start()
|
||||
logger info "start telegram event listening"
|
||||
account setUpdatesListener eventManager
|
||||
import com.pengrad.telegrambot.TelegramException
|
||||
account.setUpdatesListener(eventManager, (e: TelegramException) => {
|
||||
|
||||
if (e.response != null) {
|
||||
import com.google.gson.GsonBuilder
|
||||
logger error
|
||||
s"""Failed get updates: ${e.getMessage}
|
||||
| server responses:
|
||||
|${GsonBuilder().setPrettyPrinting().create.toJson(e.response) indent 4}
|
||||
|""".stripMargin
|
||||
}
|
||||
|
||||
if (e.getCause != null) {
|
||||
import java.net.{SocketException, SocketTimeoutException}
|
||||
import javax.net.ssl.SSLHandshakeException
|
||||
val caused = e.getCause
|
||||
caused match
|
||||
case e_timeout: (SSLHandshakeException|SocketException|SocketTimeoutException) =>
|
||||
import cc.sukazyo.messiva.log.Message
|
||||
|
||||
import scala.collection.mutable
|
||||
val log = mutable.ArrayBuffer(s"Failed get updates: Network Error")
|
||||
var current: Throwable = e_timeout
|
||||
log += s" due to: ${current.getMessage}"
|
||||
while (current.getCause != null) {
|
||||
current = current.getCause
|
||||
log += s" caused by: ${current.getClass.getSimpleName}: ${current.getMessage}"
|
||||
}
|
||||
logger error Message(log mkString "\n")
|
||||
case e_other =>
|
||||
logger error exceptionLog(e_other)
|
||||
this.daemons.reporter exception e_other
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
if config.commandLoginRefresh then
|
||||
logger info "resetting telegram command list"
|
||||
commands.automaticTGListUpdate()
|
||||
|
@ -141,7 +141,7 @@ class Scheduler {
|
||||
*/
|
||||
//noinspection ScalaWeakerAccess
|
||||
def runnerName: String =
|
||||
this.toString
|
||||
s"${this.getClass.getSimpleName}@${this.hashCode.toHexString}"
|
||||
|
||||
/** Add one task to scheduler task queue.
|
||||
* @return this scheduler for chained call.
|
||||
@ -199,11 +199,11 @@ class Scheduler {
|
||||
runtime.getState
|
||||
|
||||
/** Manually update the task scheduler.
|
||||
*
|
||||
*
|
||||
* If the inner state of the scheduler somehow changed and cannot automatically
|
||||
* update schedule states to schedule the new state, you can call this method
|
||||
* to manually let the task scheduler reschedule it.
|
||||
*
|
||||
*
|
||||
* You can also use it with some tick-guard like [[cc.sukazyo.cono.morny.util.time.WatchDog]]
|
||||
* to make the scheduler avoid fails when machine fall asleep or some else conditions.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user