Closed Bug 957926 Opened 10 years ago Closed 10 years ago

Add JS::CreateTypeError

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla29

People

(Reporter: nsm, Assigned: nsm)

References

Details

Attachments

(1 file, 1 obsolete file)

Allows creating a TypeError without actually throwing/reporting it. Used by DOM Promises to reject the promise.
Assignee: nobody → nsm.nikhil
compartment assertions and style fixes.
Attachment #8357632 - Flags: review?(jorendorff)
Attachment #8357599 - Attachment is obsolete: true
Attachment #8357599 - Flags: review?(jorendorff)
Comment on attachment 8357632 [details] [diff] [review]
Add JS::CreateTypeError.

Jeff, would you mind reviewing? Jason doesn't seem to be around.
Attachment #8357632 - Flags: review?(jorendorff) → review?(jwalden+bmo)
Comment on attachment 8357632 [details] [diff] [review]
Add JS::CreateTypeError.

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

Stealing back. Sorry for the slow review!

::: js/public/Errors.h
@@ +12,5 @@
> +
> +JS_PUBLIC_API(bool)
> +CreateTypeError(JSContext *cx, HandleString stack, HandleString fileName,
> +                uint32_t lineNumber, uint32_t columnNumber, JSErrorReport *report,
> +                HandleString message, MutableHandleValue rval);

This can go in jsapi.h.

I'm not sure this is the best signature for this. It has the virtue of completeness, though. Let's go with it.
Attachment #8357632 - Flags: review?(jwalden+bmo) → review+
Comment on attachment 8357632 [details] [diff] [review]
Add JS::CreateTypeError.

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

::: js/public/Errors.h
@@ +5,5 @@
> +
> +#ifndef js_Errors_h
> +#define js_Errors_h
> +
> +#include "jstypes.h"

This header's not enough to make this compile on its own.  You can figure out the set of extra stuff you need by replacing the contents of jsarray.cpp with #include "js/Errors.h", then adding includes to pick up the extra types.  But definitely this alone won't work.

@@ +12,5 @@
> +
> +JS_PUBLIC_API(bool)
> +CreateTypeError(JSContext *cx, HandleString stack, HandleString fileName,
> +                uint32_t lineNumber, uint32_t columnNumber, JSErrorReport *report,
> +                HandleString message, MutableHandleValue rval);

Could you do a followup patch with a documentation comment by this?

::: js/src/jsexn.cpp
@@ +879,5 @@
> +
> +JS_PUBLIC_API(bool)
> +JS::CreateTypeError(JSContext *cx, HandleString stack, HandleString fileName,
> +                    uint32_t lineNumber, uint32_t columnNumber, JSErrorReport *report,
> +                    HandleString message, MutableHandleValue rval)

Hmm, this would be better in vm/Errors.cpp, but I guess we can't do that easily because of these dependencies on local things like CopyErrorReport.  A thing for a later time, and not for you.
https://hg.mozilla.org/mozilla-central/rev/50cfbf3d30de
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: