Skip to content

Commit

Permalink
Bug 978486 - Remove nsErrorService::mErrorStringBundleKeyMap. r=froydnj
Browse files Browse the repository at this point in the history
  • Loading branch information
amccreight committed Mar 4, 2014
1 parent bcfecf4 commit cb2d3b3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 59 deletions.
18 changes: 3 additions & 15 deletions intl/strres/src/nsStringBundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,21 +718,9 @@ nsStringBundleService::FormatWithBundle(nsIStringBundle* bundle, nsresult aStatu
nsresult rv;
nsXPIDLCString key;

// then find a key into the string bundle for that particular error:
rv = mErrorService->GetErrorStringBundleKey(aStatus, getter_Copies(key));

// first try looking up the error message with the string key:
if (NS_SUCCEEDED(rv)) {
rv = bundle->FormatStringFromName(NS_ConvertASCIItoUTF16(key).get(),
(const char16_t**)argArray,
argCount, result);
}

// if the string key fails, try looking up the error message with the int key:
if (NS_FAILED(rv)) {
uint16_t code = NS_ERROR_GET_CODE(aStatus);
rv = bundle->FormatStringFromID(code, (const char16_t**)argArray, argCount, result);
}
// try looking up the error message with the int key:
uint16_t code = NS_ERROR_GET_CODE(aStatus);
rv = bundle->FormatStringFromID(code, (const char16_t**)argArray, argCount, result);

// If the int key fails, try looking up the default error message. E.g. print:
// An unknown error has occurred (0x804B0003).
Expand Down
23 changes: 0 additions & 23 deletions xpcom/base/nsErrorService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,4 @@ nsErrorService::GetErrorStringBundle(int16_t errorModule, char **result)
return NS_OK;
}

NS_IMETHODIMP
nsErrorService::RegisterErrorStringBundleKey(nsresult error, const char *stringBundleKey)
{
return mErrorStringBundleKeyMap.Put(static_cast<uint32_t>(error),
stringBundleKey);
}

NS_IMETHODIMP
nsErrorService::UnregisterErrorStringBundleKey(nsresult error)
{
return mErrorStringBundleKeyMap.Remove(static_cast<uint32_t>(error));
}

NS_IMETHODIMP
nsErrorService::GetErrorStringBundleKey(nsresult error, char **result)
{
char* value = mErrorStringBundleKeyMap.Get(static_cast<uint32_t>(error));
if (value == nullptr)
return NS_ERROR_OUT_OF_MEMORY;
*result = value;
return NS_OK;
}

////////////////////////////////////////////////////////////////////////////////
1 change: 0 additions & 1 deletion xpcom/base/nsErrorService.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class nsErrorService MOZ_FINAL : public nsIErrorService

protected:
nsInt2StrHashtable mErrorStringBundleURLMap;
nsInt2StrHashtable mErrorStringBundleKeyMap;
};

#endif // nsErrorService_h__
21 changes: 1 addition & 20 deletions xpcom/base/nsIErrorService.idl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* This service will eventually get replaced by extending xpidl to allow errors to be defined.
* (http://bugzilla.mozilla.org/show_bug.cgi?id=13423).
*/
[scriptable, uuid(e72f94b2-5f85-11d4-9877-00c04fa0cf4a)]
[scriptable, uuid(afe1f190-a3c2-11e3-a5e2-0800200c9a66)]
interface nsIErrorService : nsISupports
{
/**
Expand All @@ -31,25 +31,6 @@ interface nsIErrorService : nsISupports
* Retrieves a string bundle URL for an error module.
*/
string getErrorStringBundle(in short errorModule);

/**
* Registers a key in a string bundle for an nsresult error code. Only the code portion
* of the nsresult is used (obtained with NS_ERROR_GET_CODE) in this registration. The
* string bundle key is used to look up internationalized messages in the string bundle.
*/
void registerErrorStringBundleKey(in nsresult error, in string stringBundleKey);

/**
* Unregisters a key in a string bundle for an nsresult error code.
*/
void unregisterErrorStringBundleKey(in nsresult error);

/**
* Retrieves a key in a string bundle for an nsresult error code. If no key is registered
* for the specified nsresult's code (obtained with NS_ERROR_GET_CODE), then the stringified
* version of the nsresult code is returned.
*/
string getErrorStringBundleKey(in nsresult error);
};

%{C++
Expand Down

0 comments on commit cb2d3b3

Please sign in to comment.