2.0.8 final

This commit is contained in:
chudov
2010-04-28 08:12:37 +00:00
parent 071c45d8e2
commit 382ca8a67b
13 changed files with 1414 additions and 1411 deletions

View File

@@ -28,7 +28,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\Release\</OutputPath>
<ErrorReport>prompt</ErrorReport>
@@ -37,6 +37,7 @@
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<TargetFrameworkVersion>v1.1</TargetFrameworkVersion>
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Xml" />

View File

@@ -38,7 +38,15 @@ namespace MusicBrainz
: base ("Specified resource was not found. Perhaps it was merged or deleted.")
{
}
}
}
public sealed class MusicBrainzUnavailableException : Exception
{
public MusicBrainzUnavailableException(string message)
: base(message ?? "Service is unavailable.")
{
}
}
public sealed class MusicBrainzUnauthorizedException : Exception
{

View File

@@ -408,32 +408,47 @@ namespace MusicBrainz
if (response == null) throw new MusicBrainzNotFoundException ();
switch (response.StatusCode) {
case HttpStatusCode.BadRequest:
Monitor.Exit (server_mutex);
throw new MusicBrainzInvalidParameterException ();
case HttpStatusCode.Unauthorized:
Monitor.Exit (server_mutex);
throw new MusicBrainzUnauthorizedException ();
case HttpStatusCode.NotFound:
Monitor.Exit (server_mutex);
throw new MusicBrainzNotFoundException ();
}
switch (response.StatusCode)
{
case HttpStatusCode.BadRequest:
Monitor.Exit(server_mutex);
throw new MusicBrainzInvalidParameterException();
case HttpStatusCode.Unauthorized:
Monitor.Exit(server_mutex);
throw new MusicBrainzUnauthorizedException();
case HttpStatusCode.NotFound:
Monitor.Exit(server_mutex);
throw new MusicBrainzNotFoundException();
case HttpStatusCode.ServiceUnavailable:
Monitor.Exit(server_mutex);
throw new MusicBrainzUnavailableException(response.StatusDescription);
case HttpStatusCode.OK:
break;
default:
Monitor.Exit(server_mutex);
throw new MusicBrainzUnavailableException(response.StatusDescription);
}
bool from_cache = cache_implemented && response.IsFromCache;
if (from_cache) Monitor.Exit (server_mutex);
MusicBrainzService.OnXmlRequest (url, from_cache);
try
{
MusicBrainzService.OnXmlRequest(url, from_cache);
// Should we read the stream into a memory stream and run the XmlReader off of that?
code (new XmlTextReader (response.GetResponseStream ()));
response.Close ();
if (!from_cache) {
last_accessed = DateTime.Now;
Monitor.Exit (server_mutex);
}
// Should we read the stream into a memory stream and run the XmlReader off of that?
code(new XmlTextReader(response.GetResponseStream()));
}
finally
{
response.Close();
if (!from_cache)
{
last_accessed = DateTime.Now;
Monitor.Exit(server_mutex);
}
}
}
#endregion