Skip to content

Commit c0177b8

Browse files
committed
wrap error returned for ADO package not found
1 parent c9746cf commit c0177b8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/code/V2ServerAPICalls.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,17 @@ public override FindResults FindName(string packageName, bool includePrerelease,
364364
string response = HttpRequestCall(requestUrlV2, out errRecord);
365365
if (errRecord != null)
366366
{
367+
// usually this is for errors in calling the V2 server, but for ADO V2 this error will include package not found errors which we want to deliver in a standard message
368+
if (_isADORepo && errRecord.Exception is ResourceNotFoundException)
369+
{
370+
errRecord = new ErrorRecord(
371+
new ResourceNotFoundException($"Package with name '{packageName}' could not be found in repository '{Repository.Name}'. For ADO feed, if the package is in an upstream feed make sure you are authenticated to the upstream feed.", errRecord.Exception),
372+
"PackageNotFound",
373+
ErrorCategory.ObjectNotFound,
374+
this);
375+
response = string.Empty;
376+
}
377+
367378
return new FindResults(stringResponse: Utils.EmptyStrArray, hashtableResponse: emptyHashResponses, responseType: v2FindResponseType);
368379
}
369380

@@ -648,6 +659,17 @@ public override FindResults FindVersion(string packageName, string version, Reso
648659
string response = HttpRequestCall(requestUrlV2, out errRecord);
649660
if (errRecord != null)
650661
{
662+
// usually this is for errors in calling the V2 server, but for ADO V2 this error will include package not found errors which we want to deliver with a standard message
663+
if (_isADORepo && errRecord.Exception is ResourceNotFoundException)
664+
{
665+
errRecord = new ErrorRecord(
666+
new ResourceNotFoundException($"Package with name '{packageName}' and version '{version}' could not be found in repository '{Repository.Name}'. For ADO feed, if the package is in an upstream feed make sure you are authenticated to the upstream feed.", errRecord.Exception),
667+
"PackageNotFound",
668+
ErrorCategory.ObjectNotFound,
669+
this);
670+
response = string.Empty;
671+
}
672+
651673
return new FindResults(stringResponse: Utils.EmptyStrArray, hashtableResponse: emptyHashResponses, responseType: v2FindResponseType);
652674
}
653675

0 commit comments

Comments
 (0)