Skip to content

Commit

Permalink
improving error message
Browse files Browse the repository at this point in the history
  • Loading branch information
robaiken committed Dec 17, 2024
1 parent c654b18 commit a7f6a67
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
17 changes: 17 additions & 0 deletions common/lib/dependabot/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,23 @@ def initialize(dependencies)
end
end

class UnresolvableVersionError < DependabotError
extend T::Sig

sig { returns(T::Array[String]) }
attr_reader :dependencies

sig { params(dependencies: T::Array[String]).void }
def initialize(dependencies)
@dependencies = dependencies

msg = "Unable to determine semantic version from tags or commits for dependencies. " \
"Dependencies must have a tag or commit that references a semantic version. " \
"Affected dependencies: #{@dependencies.join(', ')}"
super(msg)
end
end

class GitDependenciesNotReachable < DependabotError
extend T::Sig

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def parse
end

dependencies_without_version = dependency_set.dependencies.select { |dep| dep.version.nil? }
raise UpdateNotPossible, dependencies_without_version.map(&:name) unless dependencies_without_version.empty?
raise UnresolvableVersionError, dependencies_without_version.map(&:name) unless dependencies_without_version.empty?

dependency_set.dependencies
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,12 @@ def mock_service_pack_request(nwo)
mock_service_pack_request("taiki-e/install-action")
end

it "raises an UpdateNotPossible error" do
it "raises an UnresolvableVersionError error" do
expect { parser.parse }.to raise_error(
Dependabot::UpdateNotPossible,
"The following dependencies could not be updated: taiki-e/install-action"
Dependabot::UnresolvableVersionError,
"Unable to determine semantic version from tags or commits for dependencies. " \
"Dependencies must have a tag or commit that references a semantic version. " \
"Affected dependencies: taiki-e/install-action"
)
end
end
Expand Down

0 comments on commit a7f6a67

Please sign in to comment.