Skip to content

Commit

Permalink
Show faulty source in error message
Browse files Browse the repository at this point in the history
  • Loading branch information
danslapman committed Jan 23, 2023
1 parent 87c7241 commit cbd49c8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ru.tinkoff.tcb.mockingbird.error

import ru.tinkoff.tcb.utils.id.SID

final case class SpawnError(source: SID[?], cause: Throwable) extends Exception(cause)
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import ru.tinkoff.tcb.mockingbird.error.CompoundError
import ru.tinkoff.tcb.mockingbird.error.EventProcessingError
import ru.tinkoff.tcb.mockingbird.error.ScenarioExecError
import ru.tinkoff.tcb.mockingbird.error.ScenarioSearchError
import ru.tinkoff.tcb.mockingbird.error.SpawnError
import ru.tinkoff.tcb.mockingbird.model.EventSourceRequest
import ru.tinkoff.tcb.mockingbird.scenario.ScenarioEngine
import ru.tinkoff.tcb.utils.circe.JsonString
Expand Down Expand Up @@ -97,7 +98,7 @@ final class EventSpawner(
.validateParDiscard(_) { sourceConf =>
(for {
_ <- Tracing.init
res <- fetch(sourceConf.request)
res <- fetch(sourceConf.request).mapError(SpawnError(sourceConf.name, _))
neRes = res.filter(_.nonEmpty)
_ <- ZIO.when(neRes.nonEmpty)(log.info(s"Отправлено в обработку: ${neRes.length}"))
_ <- ZIO
Expand All @@ -107,7 +108,7 @@ final class EventSpawner(
.mapError(CompoundError(_))
} yield ())
.catchSomeDefect { case NonFatal(ex) =>
ZIO.fail(ex)
ZIO.fail(SpawnError(sourceConf.name, ex))
}
}
.mapError(CompoundError(_))
Expand Down Expand Up @@ -137,6 +138,8 @@ final class EventSpawner(
log.warn(s"Ошибка при поиске сценария: $err")
case CallbackError(err) =>
log.warn(s"Ошибка при выполнении колбэка: $err")
case SpawnError(sid, err) =>
log.errorCause(s"Ошибка при получении события из {}", err, sid)
case NonFatal(t) =>
log.errorCause("Ошибка при получении события", t)
}
Expand Down
2 changes: 1 addition & 1 deletion backend/project/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object Settings {

val common = Seq(
organization := "ru.tinkoff",
version := "3.4.0",
version := "3.4.1",
scalaVersion := "2.13.10",
Compile / packageDoc / publishArtifact := false,
Compile / packageSrc / publishArtifact := false,
Expand Down

0 comments on commit cbd49c8

Please sign in to comment.