Skip to content

Commit

Permalink
Custom NetKAN error message when blocked by CurseForge
Browse files Browse the repository at this point in the history
  • Loading branch information
DasSkelett committed Oct 25, 2019
1 parent b966804 commit a0c0a96
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Netkan/Sources/Curse/CurseApi.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System;
using System.Diagnostics.Eventing.Reader;
using System.IO;
using System.Net;
using CKAN.NetKAN.Services;
using log4net;
Expand Down Expand Up @@ -48,7 +50,24 @@ public static Uri ResolveRedirect(Uri url)
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(redirUrl);
request.AllowAutoRedirect = false;
request.UserAgent = Net.UserAgentString;
HttpWebResponse response = (HttpWebResponse) request.GetResponse();

HttpWebResponse response;
try
{
response = (HttpWebResponse) request.GetResponse();
}
catch (WebException e)
{
if (e.Status == WebExceptionStatus.ProtocolError)
{
response = e.Response as HttpWebResponse;
if (response?.StatusCode == HttpStatusCode.Forbidden)
{
throw new Kraken("CKAN blocked by CurseForge");
}
}
throw;
}
response.Close();
while (response.Headers["Location"] != null)
{
Expand Down

0 comments on commit a0c0a96

Please sign in to comment.