@@ -190,6 +190,23 @@ class InstallationError(PipError):
190190 """General exception during installation"""
191191
192192
193+ class FailedToPrepareCandidate (InstallationError ):
194+ """Raised when we fail to prepare a candidate (i.e. fetch and generate metadata).
195+
196+ This is intentionally not a diagnostic error, since the output will be presented
197+ above this error, when this occurs. This should instead present information to the
198+ user.
199+ """
200+
201+ def __init__ (
202+ self , * , package_name : str , requirement_chain : str , failed_step : str
203+ ) -> None :
204+ super ().__init__ (f"Failed to build '{ package_name } ' when { failed_step .lower ()} " )
205+ self .package_name = package_name
206+ self .requirement_chain = requirement_chain
207+ self .failed_step = failed_step
208+
209+
193210class MissingPyProjectBuildRequires (DiagnosticPipError ):
194211 """Raised when pyproject.toml has `build-system`, but no `build-system.requires`."""
195212
@@ -384,7 +401,7 @@ def __init__(
384401 output_lines : list [str ] | None ,
385402 ) -> None :
386403 if output_lines is None :
387- output_prompt = Text ("See above for output." )
404+ output_prompt = Text ("No available output." )
388405 else :
389406 output_prompt = (
390407 Text .from_markup (f"[red][{ len (output_lines )} lines of output][/]\n " )
@@ -412,15 +429,15 @@ def __str__(self) -> str:
412429 return f"{ self .command_description } exited with { self .exit_code } "
413430
414431
415- class MetadataGenerationFailed (InstallationSubprocessError , InstallationError ):
432+ class MetadataGenerationFailed (DiagnosticPipError , InstallationError ):
416433 reference = "metadata-generation-failed"
417434
418435 def __init__ (
419436 self ,
420437 * ,
421438 package_details : str ,
422439 ) -> None :
423- super (InstallationSubprocessError , self ).__init__ (
440+ super ().__init__ (
424441 message = "Encountered error while generating package metadata." ,
425442 context = escape (package_details ),
426443 hint_stmt = "See above for details." ,
0 commit comments