* refactor: catch asset service request exceptions at the AssetServerBase level rather than in the GridAssetClient

* this is to enable logging of asset request exceptions soon
0.6.0-stable
Justin Clarke Casey 2008-06-13 18:04:01 +00:00
parent ea52e71205
commit d6519924ba
2 changed files with 37 additions and 28 deletions

View File

@ -57,6 +57,10 @@ namespace OpenSim.Framework.Communications.Cache
/// </summary> /// </summary>
/// <param name="req"></param> /// <param name="req"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="System.Exception">
/// Thrown if the request failed for some other reason than that the
/// asset cannot be found.
/// </exception>
protected abstract AssetBase GetAsset(AssetRequest req); protected abstract AssetBase GetAsset(AssetRequest req);
/// <summary> /// <summary>
@ -66,17 +70,30 @@ namespace OpenSim.Framework.Communications.Cache
/// <param name="req"></param> /// <param name="req"></param>
protected virtual void ProcessRequest(AssetRequest req) protected virtual void ProcessRequest(AssetRequest req)
{ {
AssetBase asset = GetAsset(req); AssetBase asset;
try
{
asset = GetAsset(req);
}
catch (Exception e)
{
m_log.ErrorFormat("[ASSET]: Asset request for {0} threw exception {1}", req.AssetID, e);
m_receiver.AssetNotFound(req.AssetID, req.IsTexture);
return;
}
if (asset != null) if (asset != null)
{ {
//m_log.InfoFormat("[ASSETSERVER]: Asset {0} received from asset server", req.AssetID); m_log.DebugFormat("[ASSET]: Asset {0} received from asset server", req.AssetID);
m_receiver.AssetReceived(asset, req.IsTexture); m_receiver.AssetReceived(asset, req.IsTexture);
} }
else else
{ {
//m_log.ErrorFormat("[ASSET SERVER]: Asset {0} not found by asset server", req.AssetID); m_log.WarnFormat("[ASSET]: Asset {0} not found by asset server", req.AssetID);
m_receiver.AssetNotFound(req.AssetID, req.IsTexture); m_receiver.AssetNotFound(req.AssetID, req.IsTexture);
} }

View File

@ -48,9 +48,6 @@ namespace OpenSim.Framework.Communications.Cache
#region IAssetServer Members #region IAssetServer Members
protected override AssetBase GetAsset(AssetRequest req) protected override AssetBase GetAsset(AssetRequest req)
{
Stream s = null;
try
{ {
#if DEBUG #if DEBUG
//m_log.DebugFormat("[GRID ASSET CLIENT]: Querying for {0}", req.AssetID.ToString()); //m_log.DebugFormat("[GRID ASSET CLIENT]: Querying for {0}", req.AssetID.ToString());
@ -63,7 +60,8 @@ namespace OpenSim.Framework.Communications.Cache
rc.AddQueryParameter("texture"); rc.AddQueryParameter("texture");
rc.RequestMethod = "GET"; rc.RequestMethod = "GET";
s = rc.Request();
Stream s = rc.Request();
if (s.Length > 0) if (s.Length > 0)
{ {
@ -71,16 +69,10 @@ namespace OpenSim.Framework.Communications.Cache
return (AssetBase) xs.Deserialize(s); return (AssetBase) xs.Deserialize(s);
} }
}
catch (Exception e)
{
m_log.ErrorFormat("[GRID ASSET CLIENT]: Failed to get asset {0}, {1}", req.AssetID, e);
}
return null; return null;
} }
public override void UpdateAsset(AssetBase asset) public override void UpdateAsset(AssetBase asset)
{ {
throw new Exception("The method or operation is not implemented."); throw new Exception("The method or operation is not implemented.");