SH-4490 More 'humane' error code presentation from llcorehttp callers

Wed, 11 Sep 2013 19:21:31 -0400

author
Monty Brandenberg <monty@lindenlab.com>
date
Wed, 11 Sep 2013 19:21:31 -0400
changeset 40722
779b223e385c
parent 40721
e9454aeb9ec3
child 40723
06b01c301672

SH-4490 More 'humane' error code presentation from llcorehttp callers
Added toTerseString() conversion on HttpStatus to generate a string
that's more descriptive than the hex value of the HttpStatus value
but still forms a short, searchable token (e.g. "Http_503" or
"Core_7"). Using this throughout the viewer now, no live cases
of toHex(), I believe.

indra/llcorehttp/_httplibcurl.cpp file | annotate | diff | revisions
indra/llcorehttp/_httppolicy.cpp file | annotate | diff | revisions
indra/llcorehttp/httpcommon.cpp file | annotate | diff | revisions
indra/llcorehttp/httpcommon.h file | annotate | diff | revisions
indra/llcorehttp/tests/test_httpstatus.hpp file | annotate | diff | revisions
indra/newview/llmeshrepository.cpp file | annotate | diff | revisions
indra/newview/lltexturefetch.cpp file | annotate | diff | revisions
     1.1 --- a/indra/llcorehttp/_httplibcurl.cpp	Wed Sep 11 18:00:55 2013 -0400
     1.2 +++ b/indra/llcorehttp/_httplibcurl.cpp	Wed Sep 11 19:21:31 2013 -0400
     1.3 @@ -249,7 +249,7 @@
     1.4  	{
     1.5  		LL_INFOS("CoreHttp") << "TRACE, RequestCanceled, Handle:  "
     1.6  							 << static_cast<HttpHandle>(op)
     1.7 -							 << ", Status:  " << op->mStatus.toHex()
     1.8 +							 << ", Status:  " << op->mStatus.toTerseString()
     1.9  							 << LL_ENDL;
    1.10  	}
    1.11  
    1.12 @@ -326,7 +326,7 @@
    1.13  	{
    1.14  		LL_INFOS("CoreHttp") << "TRACE, RequestComplete, Handle:  "
    1.15  							 << static_cast<HttpHandle>(op)
    1.16 -							 << ", Status:  " << op->mStatus.toHex()
    1.17 +							 << ", Status:  " << op->mStatus.toTerseString()
    1.18  							 << LL_ENDL;
    1.19  	}
    1.20  
     2.1 --- a/indra/llcorehttp/_httppolicy.cpp	Wed Sep 11 18:00:55 2013 -0400
     2.2 +++ b/indra/llcorehttp/_httppolicy.cpp	Wed Sep 11 19:21:31 2013 -0400
     2.3 @@ -174,7 +174,7 @@
     2.4  						  << " retry " << op->mPolicyRetries
     2.5  						  << " scheduled in " << (delta / HttpTime(1000))
     2.6  						  << " mS (" << (external_delta ? "external" : "internal")
     2.7 -						  << ").  Status:  " << op->mStatus.toHex()
     2.8 +						  << ").  Status:  " << op->mStatus.toTerseString()
     2.9  						  << LL_ENDL;
    2.10  	if (op->mTracing > HTTP_TRACE_OFF)
    2.11  	{
    2.12 @@ -426,7 +426,7 @@
    2.13  		LL_WARNS("CoreHttp") << "HTTP request " << static_cast<HttpHandle>(op)
    2.14  							 << " failed after " << op->mPolicyRetries
    2.15  							 << " retries.  Reason:  " << op->mStatus.toString()
    2.16 -							 << " (" << op->mStatus.toHex() << ")"
    2.17 +							 << " (" << op->mStatus.toTerseString() << ")"
    2.18  							 << LL_ENDL;
    2.19  	}
    2.20  	else if (op->mPolicyRetries)
     3.1 --- a/indra/llcorehttp/httpcommon.cpp	Wed Sep 11 18:00:55 2013 -0400
     3.2 +++ b/indra/llcorehttp/httpcommon.cpp	Wed Sep 11 19:21:31 2013 -0400
     3.3 @@ -4,7 +4,7 @@
     3.4   *
     3.5   * $LicenseInfo:firstyear=2012&license=viewerlgpl$
     3.6   * Second Life Viewer Source Code
     3.7 - * Copyright (C) 2012, Linden Research, Inc.
     3.8 + * Copyright (C) 2012-2013, Linden Research, Inc.
     3.9   *
    3.10   * This library is free software; you can redistribute it and/or
    3.11   * modify it under the terms of the GNU Lesser General Public
    3.12 @@ -174,6 +174,46 @@
    3.13  	}
    3.14  	return std::string("Unknown error");
    3.15  }
    3.16 +
    3.17 +
    3.18 +std::string HttpStatus::toTerseString() const
    3.19 +{
    3.20 +	std::ostringstream result;
    3.21 +
    3.22 +	unsigned int error_value((unsigned short) mStatus);
    3.23 +	
    3.24 +	switch (mType)
    3.25 +	{
    3.26 +	case EXT_CURL_EASY:
    3.27 +		result << "Easy_";
    3.28 +		break;
    3.29 +		
    3.30 +	case EXT_CURL_MULTI:
    3.31 +		result << "Multi_";
    3.32 +		break;
    3.33 +		
    3.34 +	case LLCORE:
    3.35 +		result << "Core_";
    3.36 +		break;
    3.37 +
    3.38 +	default:
    3.39 +		if (isHttpStatus())
    3.40 +		{
    3.41 +			result << "Http_";
    3.42 +			error_value = mType;
    3.43 +		}
    3.44 +		else
    3.45 +		{
    3.46 +			result << "Unknown_";
    3.47 +		}
    3.48 +		break;
    3.49 +	}
    3.50 +	
    3.51 +	result << error_value;
    3.52 +	return result.str();
    3.53 +}
    3.54 +
    3.55 +
    3.56  		
    3.57  } // end namespace LLCore
    3.58  
     4.1 --- a/indra/llcorehttp/httpcommon.h	Wed Sep 11 18:00:55 2013 -0400
     4.2 +++ b/indra/llcorehttp/httpcommon.h	Wed Sep 11 19:21:31 2013 -0400
     4.3 @@ -380,6 +380,14 @@
     4.4  	/// LLCore itself).
     4.5  	std::string toString() const;
     4.6  
     4.7 +	/// Convert status to a compact string representation
     4.8 +	/// of the form:  "<type>_<value>".  The <type> will be
     4.9 +	/// one of:  Core, Http, Easy, Multi, Unknown.  And
    4.10 +	/// <value> will be an unsigned integer.  More easily
    4.11 +	/// interpreted than the hex representation, it's still
    4.12 +	/// compact and easily searched.
    4.13 +	std::string toTerseString() const;
    4.14 +
    4.15  	/// Returns true if the status value represents an
    4.16  	/// HTTP response status (100 - 999).
    4.17  	bool isHttpStatus() const
     5.1 --- a/indra/llcorehttp/tests/test_httpstatus.hpp	Wed Sep 11 18:00:55 2013 -0400
     5.2 +++ b/indra/llcorehttp/tests/test_httpstatus.hpp	Wed Sep 11 19:21:31 2013 -0400
     5.3 @@ -4,7 +4,7 @@
     5.4   *
     5.5   * $LicenseInfo:firstyear=2012&license=viewerlgpl$
     5.6   * Second Life Viewer Source Code
     5.7 - * Copyright (C) 2012, Linden Research, Inc.
     5.8 + * Copyright (C) 2012-2013, Linden Research, Inc.
     5.9   *
    5.10   * This library is free software; you can redistribute it and/or
    5.11   * modify it under the terms of the GNU Lesser General Public
    5.12 @@ -277,6 +277,65 @@
    5.13  	ensure(msg == "Unknown error");
    5.14  }
    5.15  
    5.16 +
    5.17 +template <> template <>
    5.18 +void HttpStatusTestObjectType::test<8>()
    5.19 +{
    5.20 +	set_test_name("HttpStatus toHex() nominal function");
    5.21 +	
    5.22 +	HttpStatus status(404);
    5.23 +	std::string msg = status.toHex();
    5.24 +	// std::cout << "Result:  " << msg << std::endl;
    5.25 +	ensure(msg == "01940001");
    5.26 +}
    5.27 +
    5.28 +
    5.29 +template <> template <>
    5.30 +void HttpStatusTestObjectType::test<9>()
    5.31 +{
    5.32 +	set_test_name("HttpStatus toTerseString() nominal function");
    5.33 +	
    5.34 +	HttpStatus status(404);
    5.35 +	std::string msg = status.toTerseString();
    5.36 +	// std::cout << "Result:  " << msg << std::endl;
    5.37 +	ensure("Normal HTTP 404", msg == "Http_404");
    5.38 +
    5.39 +	status = HttpStatus(200);
    5.40 +	msg = status.toTerseString();
    5.41 +	// std::cout << "Result:  " << msg << std::endl;
    5.42 +	ensure("Normal HTTP 200", msg == "Http_200");
    5.43 +
    5.44 +	status = HttpStatus(200, HE_REPLY_ERROR);
    5.45 +	msg = status.toTerseString();
    5.46 +	// std::cout << "Result:  " << msg << std::endl;
    5.47 +	ensure("Unsuccessful HTTP 200", msg == "Http_200");			// No distinction for error
    5.48 +
    5.49 +	status = HttpStatus(HttpStatus::EXT_CURL_EASY, CURLE_COULDNT_CONNECT);
    5.50 +	msg = status.toTerseString();
    5.51 +	// std::cout << "Result:  " << msg << std::endl;
    5.52 +	ensure("Easy couldn't connect error", msg == "Easy_7");
    5.53 +
    5.54 +	status = HttpStatus(HttpStatus::EXT_CURL_MULTI, CURLM_OUT_OF_MEMORY);
    5.55 +	msg = status.toTerseString();
    5.56 +	// std::cout << "Result:  " << msg << std::endl;
    5.57 +	ensure("Multi out-of-memory error", msg == "Multi_3");
    5.58 +
    5.59 +	status = HttpStatus(HttpStatus::LLCORE, HE_OPT_NOT_SET);
    5.60 +	msg = status.toTerseString();
    5.61 +	// std::cout << "Result:  " << msg << std::endl;
    5.62 +	ensure("Core option not set error", msg == "Core_7");
    5.63 +
    5.64 +	status = HttpStatus(22000, 1);
    5.65 +	msg = status.toTerseString();
    5.66 +	// std::cout << "Result:  " << msg << std::endl;
    5.67 +	ensure("Undecodable error", msg == "Unknown_1");
    5.68 +
    5.69 +	status = HttpStatus(22000, -1);
    5.70 +	msg = status.toTerseString();
    5.71 +	// std::cout << "Result:  " << msg << std::endl;
    5.72 +	ensure("Undecodable error 65535", msg == "Unknown_65535");
    5.73 +}
    5.74 +
    5.75  } // end namespace tut
    5.76  
    5.77  #endif	// TEST_HTTP_STATUS_H
     6.1 --- a/indra/newview/llmeshrepository.cpp	Wed Sep 11 18:00:55 2013 -0400
     6.2 +++ b/indra/newview/llmeshrepository.cpp	Wed Sep 11 19:21:31 2013 -0400
     6.3 @@ -688,7 +688,7 @@
     6.4  	// Log details.
     6.5  	LL_WARNS(LOG_MESH) << "Error in stage:  " << stage
     6.6  					   << ", Reason:  " << status.toString()
     6.7 -					   << " (" << status.toHex() << ")" << LL_ENDL;
     6.8 +					   << " (" << status.toTerseString() << ")" << LL_ENDL;
     6.9  	if (content.has("error"))
    6.10  	{
    6.11  		const LLSD& err = content["error"];
    6.12 @@ -1205,7 +1205,7 @@
    6.13  				{
    6.14  					LL_WARNS(LOG_MESH) << "HTTP GET request failed for skin info on mesh " << mID
    6.15  									   << ".  Reason:  " << mHttpStatus.toString()
    6.16 -									   << " (" << mHttpStatus.toHex() << ")"
    6.17 +									   << " (" << mHttpStatus.toTerseString() << ")"
    6.18  									   << LL_ENDL;
    6.19  					delete handler;
    6.20  					ret = false;
    6.21 @@ -1298,7 +1298,7 @@
    6.22  				{
    6.23  					LL_WARNS(LOG_MESH) << "HTTP GET request failed for decomposition mesh " << mID
    6.24  									   << ".  Reason:  " << mHttpStatus.toString()
    6.25 -									   << " (" << mHttpStatus.toHex() << ")"
    6.26 +									   << " (" << mHttpStatus.toTerseString() << ")"
    6.27  									   << LL_ENDL;
    6.28  					delete handler;
    6.29  					ret = false;
    6.30 @@ -1389,7 +1389,7 @@
    6.31  				{
    6.32  					LL_WARNS(LOG_MESH) << "HTTP GET request failed for physics shape on mesh " << mID
    6.33  									   << ".  Reason:  " << mHttpStatus.toString()
    6.34 -									   << " (" << mHttpStatus.toHex() << ")"
    6.35 +									   << " (" << mHttpStatus.toTerseString() << ")"
    6.36  									   << LL_ENDL;
    6.37  					delete handler;
    6.38  					ret = false;
    6.39 @@ -1486,7 +1486,7 @@
    6.40  		{
    6.41  			LL_WARNS(LOG_MESH) << "HTTP GET request failed for mesh header " << mID
    6.42  							   << ".  Reason:  " << mHttpStatus.toString()
    6.43 -							   << " (" << mHttpStatus.toHex() << ")"
    6.44 +							   << " (" << mHttpStatus.toTerseString() << ")"
    6.45  							   << LL_ENDL;
    6.46  			delete handler;
    6.47  			retval = false;
    6.48 @@ -1568,7 +1568,7 @@
    6.49  				{
    6.50  					LL_WARNS(LOG_MESH) << "HTTP GET request failed for LOD on mesh " << mID
    6.51  									   << ".  Reason:  " << mHttpStatus.toString()
    6.52 -									   << " (" << mHttpStatus.toHex() << ")"
    6.53 +									   << " (" << mHttpStatus.toTerseString() << ")"
    6.54  									   << LL_ENDL;
    6.55  					delete handler;
    6.56  					retval = false;
    6.57 @@ -2196,7 +2196,7 @@
    6.58  			mHttpStatus = mHttpRequest->getStatus();
    6.59  		
    6.60  			LL_WARNS(LOG_MESH) << "Couldn't issue request for full model upload.  Reason:  " << mHttpStatus.toString()
    6.61 -							   << " (" << mHttpStatus.toHex() << ")"
    6.62 +							   << " (" << mHttpStatus.toTerseString() << ")"
    6.63  							   << LL_ENDL;
    6.64  		}
    6.65  		else
    6.66 @@ -2244,7 +2244,7 @@
    6.67  		mHttpStatus = mHttpRequest->getStatus();
    6.68  		
    6.69  		LL_WARNS(LOG_MESH) << "Couldn't issue request for model fee.  Reason:  " << mHttpStatus.toString()
    6.70 -						   << " (" << mHttpStatus.toHex() << ")"
    6.71 +						   << " (" << mHttpStatus.toTerseString() << ")"
    6.72  						   << LL_ENDL;
    6.73  	}
    6.74  	else
    6.75 @@ -2285,7 +2285,7 @@
    6.76  		if (! status)
    6.77  		{
    6.78  			LL_WARNS(LOG_MESH) << "Upload failed.  Reason:  " << reason
    6.79 -							   << " (" << status.toHex() << ")"
    6.80 +							   << " (" << status.toTerseString() << ")"
    6.81  							   << LL_ENDL;
    6.82  
    6.83  			// Build a fake body for the alert generator
    6.84 @@ -2349,7 +2349,7 @@
    6.85  		if (! status)
    6.86  		{
    6.87  			LL_WARNS(LOG_MESH) << "Fee request failed.  Reason:  " << reason
    6.88 -							   << " (" << status.toHex() << ")"
    6.89 +							   << " (" << status.toTerseString() << ")"
    6.90  							   << LL_ENDL;
    6.91  
    6.92  			// Build a fake body for the alert generator
    6.93 @@ -2584,7 +2584,7 @@
    6.94  		if (par_status != status)
    6.95  		{
    6.96  			LL_WARNS_ONCE(LOG_MESH) << "Non-206 successful status received for fetch:  "
    6.97 -									<< status.toHex() << LL_ENDL;
    6.98 +									<< status.toTerseString() << LL_ENDL;
    6.99  		}
   6.100  		
   6.101  		LLCore::BufferArray * body(response->getBody());
   6.102 @@ -2633,7 +2633,7 @@
   6.103  {
   6.104  	LL_WARNS(LOG_MESH) << "Error during mesh header handling.  ID:  " << mMeshParams.getSculptID()
   6.105  					   << ", Reason:  " << status.toString()
   6.106 -					   << " (" << status.toHex() << ").  Not retrying."
   6.107 +					   << " (" << status.toTerseString() << ").  Not retrying."
   6.108  					   << LL_ENDL;
   6.109  
   6.110  	// Can't get the header so none of the LODs will be available
   6.111 @@ -2739,7 +2739,7 @@
   6.112  {
   6.113  	LL_WARNS(LOG_MESH) << "Error during mesh LOD handling.  ID:  " << mMeshParams.getSculptID()
   6.114  					   << ", Reason:  " << status.toString()
   6.115 -					   << " (" << status.toHex() << ").  Not retrying."
   6.116 +					   << " (" << status.toTerseString() << ").  Not retrying."
   6.117  					   << LL_ENDL;
   6.118  
   6.119  	LLMutexLock lock(gMeshRepo.mThread->mMutex);
   6.120 @@ -2783,7 +2783,7 @@
   6.121  {
   6.122  	LL_WARNS(LOG_MESH) << "Error during mesh skin info handling.  ID:  " << mMeshID
   6.123  					   << ", Reason:  " << status.toString()
   6.124 -					   << " (" << status.toHex() << ").  Not retrying."
   6.125 +					   << " (" << status.toTerseString() << ").  Not retrying."
   6.126  					   << LL_ENDL;
   6.127  
   6.128  	// *TODO:  Mark mesh unavailable on error.  For now, simply leave
   6.129 @@ -2826,7 +2826,7 @@
   6.130  {
   6.131  	LL_WARNS(LOG_MESH) << "Error during mesh decomposition handling.  ID:  " << mMeshID
   6.132  					   << ", Reason:  " << status.toString()
   6.133 -					   << " (" << status.toHex() << ").  Not retrying."
   6.134 +					   << " (" << status.toTerseString() << ").  Not retrying."
   6.135  					   << LL_ENDL;
   6.136  	// *TODO:  Mark mesh unavailable on error.  For now, simply leave
   6.137  	// request unfulfilled rather than retry forever.
   6.138 @@ -2868,7 +2868,7 @@
   6.139  {
   6.140  	LL_WARNS(LOG_MESH) << "Error during mesh physics shape handling.  ID:  " << mMeshID
   6.141  					   << ", Reason:  " << status.toString()
   6.142 -					   << " (" << status.toHex() << ").  Not retrying."
   6.143 +					   << " (" << status.toTerseString() << ").  Not retrying."
   6.144  					   << LL_ENDL;
   6.145  	// *TODO:  Mark mesh unavailable on error
   6.146  }
     7.1 --- a/indra/newview/lltexturefetch.cpp	Wed Sep 11 18:00:55 2013 -0400
     7.2 +++ b/indra/newview/lltexturefetch.cpp	Wed Sep 11 19:21:31 2013 -0400
     7.3 @@ -1552,7 +1552,7 @@
     7.4  				else
     7.5  				{
     7.6  					llinfos << "HTTP GET failed for: " << mUrl
     7.7 -							<< " Status: " << mGetStatus.toHex()
     7.8 +							<< " Status: " << mGetStatus.toTerseString()
     7.9  							<< " Reason: '" << mGetReason << "'"
    7.10  							<< llendl;
    7.11  				}
    7.12 @@ -1896,7 +1896,7 @@
    7.13  	LLCore::HttpStatus status(response->getStatus());
    7.14  	
    7.15  	LL_DEBUGS("Texture") << "HTTP COMPLETE: " << mID
    7.16 -			 << " status: " << status.toHex()
    7.17 +			 << " status: " << status.toTerseString()
    7.18  			 << " '" << status.toString() << "'"
    7.19  			 << llendl;
    7.20  //	unsigned int offset(0), length(0), full_length(0);
    7.21 @@ -1912,7 +1912,7 @@
    7.22  		success = false;
    7.23  		std::string reason(status.toString());
    7.24  		setGetStatus(status, reason);
    7.25 -		llwarns << "CURL GET FAILED, status: " << status.toHex()
    7.26 +		llwarns << "CURL GET FAILED, status: " << status.toTerseString()
    7.27  				<< " reason: " << reason << llendl;
    7.28  	}
    7.29  	else
    7.30 @@ -3781,7 +3781,7 @@
    7.31  		else
    7.32  		{
    7.33  			LL_WARNS("Texture") << "Error delivering asset metrics to grid.  Status:  "
    7.34 -								<< status.toHex()
    7.35 +								<< status.toTerseString()
    7.36  								<< ", Reason:  " << status.toString() << LL_ENDL;
    7.37  		}
    7.38  	}
    7.39 @@ -4470,7 +4470,7 @@
    7.40  
    7.41  			LL_WARNS("Texture") << "Couldn't issue HTTP request in debugger for texture "
    7.42  								<< mFetchingHistory[i].mID
    7.43 -								<< ", status: " << status.toHex()
    7.44 +								<< ", status: " << status.toTerseString()
    7.45  								<< " reason:  " << status.toString()
    7.46  								<< LL_ENDL;
    7.47  			mFetchingHistory[i].mCurlState = FetchEntry::CURL_DONE;
    7.48 @@ -4863,7 +4863,7 @@
    7.49  	else //failed
    7.50  	{
    7.51  		llinfos << "Fetch Debugger : CURL GET FAILED,  ID = " << fetch.mID
    7.52 -				<< ", status: " << status.toHex()
    7.53 +				<< ", status: " << status.toTerseString()
    7.54  				<< " reason:  " << status.toString() << llendl;
    7.55  	}
    7.56  }

mercurial