Skip to content

Commit

Permalink
improvement: Only log if failed to resolve mtags at all
Browse files Browse the repository at this point in the history
Previously, we would log an error and then try to download stable presentation compiler, which could be misleading. Now we only print an error if we fail to resolve any mtags.
  • Loading branch information
tgodzik committed Dec 21, 2023
1 parent 89540f8 commit 6b9babd
Showing 1 changed file with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,6 @@ object MtagsResolver {
original: Option[String],
resolveType: ResolveType.Value = ResolveType.Regular,
): Option[MtagsBinaries] = {
def logError(e: Throwable): Unit = {
val msg = s"Failed to fetch mtags for ${scalaVersion}"
e match {
case _: SimpleResolutionError =>
// no need to log traces for coursier error
// all explanation is in message
scribe.error(msg + "\n" + e.getMessage())
case _ =>
scribe.error(msg, e)
}
}

def fetch(tries: Int = 0): State = logResolution {
try {
Expand Down Expand Up @@ -138,8 +127,7 @@ object MtagsResolver {
)
} catch {
case NonFatal(e) =>
logError(e)
State.Failure(System.currentTimeMillis(), tries)
State.Failure(System.currentTimeMillis(), tries, e)
}
}
def shouldResolveAgain(failure: State.Failure): Boolean = {
Expand Down Expand Up @@ -196,6 +184,18 @@ object MtagsResolver {
},
)

def logError(e: Throwable): Unit = {
val msg = s"Failed to fetch mtags for ${scalaVersion}"
e match {
case _: SimpleResolutionError =>
// no need to log traces for coursier error
// all explanation is in message
scribe.error(msg + "\n" + e.getMessage())
case _ =>
scribe.error(msg, e)
}
}

computed match {
case State.Success(v) =>
Some(v)
Expand Down Expand Up @@ -226,8 +226,10 @@ object MtagsResolver {
ResolveType.Nightly,
)
}
case _ =>
case failure: State.Failure =>
logError(failure.exception)
None
case _ => None
}
}
}
Expand Down Expand Up @@ -291,7 +293,8 @@ object MtagsResolver {
object State {
val maxTriesInARow: Int = 2
case class Success(v: MtagsBinaries.Artifacts) extends State
case class Failure(lastTryMillis: Long, tries: Int) extends State
case class Failure(lastTryMillis: Long, tries: Int, exception: Throwable)
extends State
}
}

Expand Down

0 comments on commit 6b9babd

Please sign in to comment.