Skip to content

Commit

Permalink
Adds additional error handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
sachin-sandhu committed Jan 16, 2025
1 parent fbf0869 commit d5f5a93
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ class PnpmErrorHandler
# socket hang up error code
SOCKET_HANG_UP = /socket hang up/

# ERR_PNPM_CATALOG_ENTRY_NOT_FOUND_FOR_SPEC error
ERR_PNPM_CATALOG_ENTRY_NOT_FOUND_FOR_SPEC = /ERR_PNPM_CATALOG_ENTRY_NOT_FOUND_FOR_SPEC/

# duplicate package error code
DUPLICATE_PACKAGE = /Found duplicates/

Expand Down Expand Up @@ -407,15 +410,16 @@ def initialize(dependencies:, dependency_files:)
# Handles errors with specific to yarn error codes
sig { params(error: SharedHelpers::HelperSubprocessFailed).void }
def handle_pnpm_error(error)
if error.message.match?(DUPLICATE_PACKAGE) || error.message.match?(ERR_PNPM_NO_VERSIONS)
if error.message.match?(DUPLICATE_PACKAGE) || error.message.match?(ERR_PNPM_NO_VERSIONS) ||
error.message.match?(ERR_PNPM_CATALOG_ENTRY_NOT_FOUND_FOR_SPEC)

raise DependencyFileNotResolvable, "Error resolving dependency"
end

## Clean error message from ANSI escape codes
return unless error.message.match?(ECONNRESET_ERROR) || error.message.match?(SOCKET_HANG_UP)

raise InconsistentRegistryResponse, "Error resolving dependency"
raise InconsistentRegistryResponse, "Inconsistent registry response while resolving dependency"
end
end
end
Expand Down

0 comments on commit d5f5a93

Please sign in to comment.