Skip to content

Commit

Permalink
improve error messages when no main classes can be found
Browse files Browse the repository at this point in the history
  • Loading branch information
cvogt authored and tgodzik committed Mar 7, 2025
1 parent 29a72b6 commit d687486
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -882,10 +882,20 @@ class WorkspaceLspService(
}
}(_ => true)
.flatMap { mains =>
mains.headOption.fold(
mains.fold(
Future.failed[DebugSessionParams](
DiscoveryFailures
.NoMainClassFoundException(unresolvedParams.mainClass)
Option(unresolvedParams.buildTarget)
.map(buildTarget =>
DiscoveryFailures
.ClassNotFoundInBuildTargetException(
unresolvedParams.mainClass,
buildTarget,
)
)
.getOrElse(
DiscoveryFailures
.NoMainClassFoundException(unresolvedParams.mainClass)
)
)
)(Future.successful(_))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ object DiscoveryFailures {
className: String,
buildTarget: String,
) extends Exception(
s"Class '$className' not found in build target '${buildTarget}'"
s"Main class '$className' not found in build target '${buildTarget}' (not considering dependencies)"
)

case class NoMainClassFoundException(
className: String
) extends Exception(
s"Class '$className' not found in any build target"
s"Main class '$className' not found in any build target (not considering dependencies)"
)

case class BuildTargetNotFoundForPathException(path: AbsolutePath)
Expand Down

0 comments on commit d687486

Please sign in to comment.