Bug 1341452 - Write nsresult name in MediaResult::Description() - r=jya

Also only show the separator between code and message if there actually is a
message.

MozReview-Commit-ID: 6Cb4YnFi2fT

--HG--
extra : rebase_source : 98183484972fa1c910f0e5e7fe4d46c763e97eb8
This commit is contained in:
Gerald Squelart 2017-02-21 16:30:44 +11:00
parent dbb8cb16a7
commit c76a0fb731

View File

@ -7,6 +7,8 @@
#ifndef MediaResult_h_
#define MediaResult_h_
#include "nsString.h" // Required before 'mozilla/ErrorNames.h'!?
#include "mozilla/ErrorNames.h"
#include "nsError.h"
#include "nsPrintfCString.h"
@ -51,7 +53,13 @@ public:
if (NS_SUCCEEDED(mCode)) {
return nsCString();
}
return nsPrintfCString("0x%08" PRIx32 ": %s", static_cast<uint32_t>(mCode), mMessage.get());
nsCString name;
GetErrorName(mCode, static_cast<nsACString&>(name));
return nsPrintfCString("%s (0x%08" PRIx32 ")%s%s",
name.get(),
static_cast<uint32_t>(mCode),
mMessage.IsEmpty() ? "" : " - ",
mMessage.get());
}
private: