Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle exceptions when occures NuGet garelly return 503:Server Unavailable #1

Open
altrive opened this issue Feb 11, 2015 · 0 comments

Comments

@altrive
Copy link
Owner

altrive commented Feb 11, 2015

NuGet garelly may return 503:Server Unavailable in some cases.
but following default exception message is difficult to understand.

Exception calling "InstallPackage" with "4" argument(s): "One or more errors occurred."
At C:\Users\altrive\Documents\WindowsPowerShell\Modules\PSNuGet\Scripts\Use-NuGetPackage.ps1:47 char:9
+         $manager.InstallPackage($PackageId, $Version, $true, $Include ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : AggregateException

It need to handle exception properly.

Error Details

$error[0].exception | select *

ErrorRecord                 : Exception calling "InstallPackage" with "4" argument(s): "One or more errors occurred."
StackTrace                  :    at System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exception 
                              exception, Type typeToThrow, String methodName, Int32 numArgs, MemberInfo memberInfo)
                                 at CallSite.Target(Closure , CallSite , PackageManager , String , String , Boolean , SwitchParameter )
                                 at System.Dynamic.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet](CallSite site, T0 arg0, T1 arg1, 
                              T2 arg2, T3 arg3, T4 arg4)
                                 at System.Management.Automation.Interpreter.DynamicInstruction`6.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
WasThrownFromThrowStatement : False
Message                     : Exception calling "InstallPackage" with "4" argument(s): "One or more errors occurred."
Data                        : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException              : System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: An error 
                              occurred while loading packages from 'https://go.microsoft.com/fwlink/?LinkID=397631&clcid=0x409': The remote 
                              server returned an error: (503) Server Unavailable. ---> System.Net.WebException: The remote server returned 
                              an error: (503) Server Unavailable.
                                 at System.Net.HttpWebRequest.GetResponse()
                                 at NuGet.RequestHelper.GetResponse(Func`1 createRequest, Action`1 prepareRequest, IProxyCache proxyCache, 
                              ICredentialCache credentialCache, ICredentialProvider credentialProvider)
                                 at NuGet.HttpClient.GetResponse()
                                 at NuGet.RedirectedHttpClient.GetResponseUri(HttpClient client)
                                 at NuGet.RedirectedHttpClient.EnsureClient()
                                 at System.Lazy`1.CreateValue()
                                 at System.Lazy`1.LazyInitValue()
                                 at NuGet.RedirectedHttpClient.get_CachedClient()
                                 at NuGet.RedirectedHttpClient.get_Uri()
                                 at NuGet.DataServicePackageRepository.get_Context()
                                 at NuGet.DataServicePackageRepository.FindPackagesById(String packageId)
                                 --- End of inner exception stack trace ---
                                 at NuGet.DataServicePackageRepository.FindPackagesById(String packageId)
                                 at NuGet.PackageRepositoryExtensions.FindPackagesById(IPackageRepository repository, String packageId)
                                 at System.Threading.Tasks.Task`1.InnerInvoke()
                                 at System.Threading.Tasks.Task.Execute()
                                 --- End of inner exception stack trace ---
                                 at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken 
                              cancellationToken)
                                 at NuGet.AggregateRepository.FindPackagesById(String packageId)
                                 at NuGet.PackageRepositoryExtensions.FindPackage(IPackageRepository repository, String packageId, 
                              SemanticVersion version, IPackageConstraintProvider constraintProvider, Boolean allowPrereleaseVersions, 
                              Boolean allowUnlisted)
                                 at NuGet.PackageRepositoryHelper.ResolvePackage(IPackageRepository sourceRepository, IPackageRepository 
                              localRepository, IPackageConstraintProvider constraintProvider, String packageId, SemanticVersion version, 
                              Boolean allowPrereleaseVersions)
                                 at NuGet.PackageManager.InstallPackage(String packageId, SemanticVersion version, Boolean 
                              ignoreDependencies, Boolean allowPrereleaseVersions)
                                 at CallSite.Target(Closure , CallSite , PackageManager , String , String , Boolean , SwitchParameter )
                              ---> (Inner Exception #0) System.InvalidOperationException: An error occurred while loading packages from 
                              'https://go.microsoft.com/fwlink/?LinkID=397631&clcid=0x409': The remote server returned an error: (503) 
                              Server Unavailable. ---> System.Net.WebException: The remote server returned an error: (503) Server 
                              Unavailable.
                                 at System.Net.HttpWebRequest.GetResponse()
                                 at NuGet.RequestHelper.GetResponse(Func`1 createRequest, Action`1 prepareRequest, IProxyCache proxyCache, 
                              ICredentialCache credentialCache, ICredentialProvider credentialProvider)
                                 at NuGet.HttpClient.GetResponse()
                                 at NuGet.RedirectedHttpClient.GetResponseUri(HttpClient client)
                                 at NuGet.RedirectedHttpClient.EnsureClient()
                                 at System.Lazy`1.CreateValue()
                                 at System.Lazy`1.LazyInitValue()
                                 at NuGet.RedirectedHttpClient.get_CachedClient()
                                 at NuGet.RedirectedHttpClient.get_Uri()
                                 at NuGet.DataServicePackageRepository.get_Context()
                                 at NuGet.DataServicePackageRepository.FindPackagesById(String packageId)
                                 --- End of inner exception stack trace ---
                                 at NuGet.DataServicePackageRepository.FindPackagesById(String packageId)
                                 at NuGet.PackageRepositoryExtensions.FindPackagesById(IPackageRepository repository, String packageId)
                                 at System.Threading.Tasks.Task`1.InnerInvoke()
                                 at System.Threading.Tasks.Task.Execute()<---

TargetSite                  : Void CheckActionPreference(System.Management.Automation.Language.FunctionContext, System.Exception)
HelpLink                    : 
Source                      : System.Management.Automation
HResult                     : -2146233087
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant