Closed Bug 907327 Opened 11 years ago Closed 10 years ago

Add mapping from XPCOM error codes (nsresult) to symbolic error names like PR_ErrorToString does for NSPR errors

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla36

People

(Reporter: briansmith, Assigned: anujagarwal464)

References

(Blocks 1 open bug)

Details

Attachments

(4 files, 4 obsolete files)

This will be useful for improving error messages in tests. This kind of error mapping is already being done by the networking dashboard. I'm just proposing it to be moved to XPCOM.
Assignee: nobody → brian
Status: NEW → ASSIGNED
Blocks: 896981
Assignee: brian → nobody
Brian, did you just not see this as useful and dropped it, or did you just decide to focus your efforts elsewhere, still seeing this as useful?
Flags: needinfo?(brian)
(In reply to Nathan Froyd (:froydnj) from comment #2)
> Brian, did you just not see this as useful and dropped it, or did you just
> decide to focus your efforts elsewhere, still seeing this as useful?

I think it would be helpful. This is one of the many bugs I dropped when I stopped working for MoCo. It would be great if somebody picked it up.
Flags: needinfo?(brian)
I may take a look at finishing this out in a bit.

Related to this, I noticed that js/xpconnect/src/xpc.msg maintains a mapping of (some) error codes to their symbolic names (plus some string explanations too).

Perhaps both use cases can be unified in some way.
Ryan, are you still looking at this?
Flags: needinfo?(jryans)
No, I haven't done anything here yet.  Feel free to take it if you'd like to!
Flags: needinfo?(jryans)
Anuj, is this something you would be interested in doing?
Flags: needinfo?(anujagarwal464)
ok :)
Assignee: nobody → anujagarwal464
Flags: needinfo?(anujagarwal464)
Attached patch bug792989-part1.diff (obsolete) — Splinter Review
Attachment #8507905 - Flags: feedback?(nfroyd)
Attached patch bug792989-part2.diff (obsolete) — Splinter Review
Attachment #8507906 - Flags: feedback?(nfroyd)
Comment on attachment 8507905 [details] [diff] [review]
bug792989-part1.diff

Review of attachment 8507905 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, just some small nits.

::: xpcom/base/ErrorNames.cpp
@@ +1,1 @@
> +#include "mozilla/ErrorNames.h"

This file needs a license header at the top, as well as appropriate editor modelines.  Please see:

https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#Mode_Line

@@ +1,2 @@
> +#include "mozilla/ErrorNames.h"
> +#include "mozilla/ArrayUtils.h"

Please alphabetically sort the header #includes.

@@ +2,5 @@
> +#include "mozilla/ArrayUtils.h"
> +#include "nsString.h"
> +#include "prerror.h"
> +
> +using namespace mozilla;

This bit shouldn't be necessary, since all the interesting things in this file are defined inside |namespace mozilla { }|.

@@ +26,5 @@
> +
> +namespace mozilla {
> +
> +void
> +GetErrorName(nsresult rv, /*out*/ nsACString & name)

No space between nsACString and &, please.  The /*out*/ comment is also unnecessary.

::: xpcom/base/ErrorNames.h
@@ +16,5 @@
> +// GetErrorName(NS_OK, name) will result in name == "NS_OK".
> +// When the symbolic name is unknown, name will be of the form
> +// "NS_ERROR_GENERATE_SUCCESS(<module>, <code>)" or
> +// "NS_ERROR_GENERATE_FAILURE(<module>, <code>)".
> +void GetErrorName(nsresult rv, /*out*/ nsACString & name);

Likewise with the |name| parameter here.

::: xpcom/base/moz.build
@@ +88,5 @@
>  
>  # nsDebugImpl isn't unified because we disable PGO so that NS_ABORT_OOM isn't
>  # optimized away oddly.
>  SOURCES += [
> +    'ErrorNames.cpp',

Please include this in UNIFIED_SOURCES instead of SOURCES.
Attachment #8507905 - Flags: feedback?(nfroyd) → feedback+
Comment on attachment 8507906 [details] [diff] [review]
bug792989-part2.diff

Review of attachment 8507906 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, just requires some small changes.

::: netwerk/base/src/Dashboard.cpp
@@ +914,3 @@
>          }
> +    }
> +    nsCString errorCString;

I think I'd make this an nsAutoCString.

::: xpcom/base/ErrorNames.cpp
@@ -26,5 @@
>  
>  namespace mozilla {
>  
>  void
> -GetErrorName(nsresult rv, /*out*/ nsACString & name)

This change can be removed once you have nsACString& in the previous patch.

::: xpcom/base/ErrorNames.h
@@ +16,5 @@
>  // GetErrorName(NS_OK, name) will result in name == "NS_OK".
>  // When the symbolic name is unknown, name will be of the form
>  // "NS_ERROR_GENERATE_SUCCESS(<module>, <code>)" or
>  // "NS_ERROR_GENERATE_FAILURE(<module>, <code>)".
> +void GetErrorName(nsresult rv, /*out*/ nsACString &name);

Likewise.
Attachment #8507906 - Flags: feedback?(nfroyd) → feedback+
Attached patch bug792989-part1.diff (obsolete) — Splinter Review
Attachment #8507905 - Attachment is obsolete: true
Attachment #8507906 - Attachment is obsolete: true
Attachment #8508015 - Flags: review?(nfroyd)
Attached patch bug792989-part2.diff (obsolete) — Splinter Review
Attachment #8508016 - Flags: review?(nfroyd)
Comment on attachment 8508015 [details] [diff] [review]
bug792989-part1.diff

Review of attachment 8508015 [details] [diff] [review]:
-----------------------------------------------------------------

::: xpcom/base/moz.build
@@ +40,5 @@
>  
>  EXPORTS += [
>      'CodeAddressService.h',
>      'ErrorList.h',
> +    'ErrorNames.h',

It looks like this should be exported in EXPORTS.mozilla according to your try build.
Attachment #8508015 - Flags: review?(nfroyd)
Attachment #8508015 - Attachment is obsolete: true
Attachment #8508178 - Flags: review?(nfroyd)
Attachment #8508178 - Flags: review?(nfroyd) → review+
Comment on attachment 8508016 [details] [diff] [review]
bug792989-part2.diff

Review of attachment 8508016 [details] [diff] [review]:
-----------------------------------------------------------------

::: netwerk/base/src/Dashboard.cpp
@@ +1,1 @@
> +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */

Please remove this line.
Attachment #8508016 - Flags: review?(nfroyd) → feedback+
Attachment #8508016 - Attachment is obsolete: true
Attachment #8509566 - Flags: review?(nfroyd)
Attachment #8509566 - Flags: review?(nfroyd) → review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/9965ddd32fd6
https://hg.mozilla.org/mozilla-central/rev/2a1cd73f279c
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: