mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 20:33:10 +00:00
LibJS: Make AggregateError inherit from Error
This is our way of implementing the [[ErrorData]] internal slot, which is being used in Object.prototype.toString().
This commit is contained in:
parent
0e8cbfb7b5
commit
c503a28e19
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <LibJS/Runtime/AggregateError.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
|
||||
namespace JS {
|
||||
|
@ -16,7 +16,7 @@ AggregateError* AggregateError::create(GlobalObject& global_object)
|
|||
}
|
||||
|
||||
AggregateError::AggregateError(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Error(prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -6,12 +6,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
class AggregateError : public Object {
|
||||
JS_OBJECT(AggregateError, Object);
|
||||
class AggregateError : public Error {
|
||||
JS_OBJECT(AggregateError, Error);
|
||||
|
||||
public:
|
||||
static AggregateError* create(GlobalObject&);
|
||||
|
|
|
@ -10,6 +10,8 @@ test("result for various object types", () => {
|
|||
expect(oToString([])).toBe("[object Array]");
|
||||
expect(oToString(function () {})).toBe("[object Function]");
|
||||
expect(oToString(new Error())).toBe("[object Error]");
|
||||
expect(oToString(new TypeError())).toBe("[object Error]");
|
||||
expect(oToString(new AggregateError([]))).toBe("[object Error]");
|
||||
expect(oToString(new Boolean())).toBe("[object Boolean]");
|
||||
expect(oToString(new Number())).toBe("[object Number]");
|
||||
expect(oToString(new Date())).toBe("[object Date]");
|
||||
|
|
Loading…
Reference in a new issue