mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 08:03:29 +00:00
commit
32443bf5ff
@ -92,37 +92,37 @@ JSHandle<JSTaggedValue> ErrorHelper::GetErrorName(JSThread *thread, const JSHand
|
||||
{
|
||||
auto globalConst = thread->GlobalConstants();
|
||||
if (name->IsUndefined()) {
|
||||
TaggedObject *errorKey = nullptr;
|
||||
JSHandle<JSTaggedValue> errorKey;
|
||||
switch (errorType) {
|
||||
case ErrorType::RANGE_ERROR:
|
||||
errorKey = reinterpret_cast<TaggedObject *>(*globalConst->GetHandledRangeErrorString());
|
||||
errorKey = globalConst->GetHandledRangeErrorString();
|
||||
break;
|
||||
case ErrorType::EVAL_ERROR:
|
||||
errorKey = reinterpret_cast<TaggedObject *>(*globalConst->GetHandledEvalErrorString());
|
||||
errorKey = globalConst->GetHandledEvalErrorString();
|
||||
break;
|
||||
case ErrorType::REFERENCE_ERROR:
|
||||
errorKey = reinterpret_cast<TaggedObject *>(*globalConst->GetHandledReferenceErrorString());
|
||||
errorKey = globalConst->GetHandledReferenceErrorString();
|
||||
break;
|
||||
case ErrorType::TYPE_ERROR:
|
||||
errorKey = reinterpret_cast<TaggedObject *>(*globalConst->GetHandledTypeErrorString());
|
||||
errorKey = globalConst->GetHandledTypeErrorString();
|
||||
break;
|
||||
case ErrorType::AGGREGATE_ERROR:
|
||||
errorKey = reinterpret_cast<TaggedObject *>(*globalConst->GetHandledAggregateErrorString());
|
||||
errorKey = globalConst->GetHandledAggregateErrorString();
|
||||
break;
|
||||
case ErrorType::URI_ERROR:
|
||||
errorKey = reinterpret_cast<TaggedObject *>(*globalConst->GetHandledURIErrorString());
|
||||
errorKey = globalConst->GetHandledURIErrorString();
|
||||
break;
|
||||
case ErrorType::SYNTAX_ERROR:
|
||||
errorKey = reinterpret_cast<TaggedObject *>(*globalConst->GetHandledSyntaxErrorString());
|
||||
errorKey = globalConst->GetHandledSyntaxErrorString();
|
||||
break;
|
||||
case ErrorType::OOM_ERROR:
|
||||
errorKey = reinterpret_cast<TaggedObject *>(*globalConst->GetHandledOOMErrorString());
|
||||
errorKey = globalConst->GetHandledOOMErrorString();
|
||||
break;
|
||||
default:
|
||||
errorKey = reinterpret_cast<TaggedObject *>(*globalConst->GetHandledErrorString());
|
||||
errorKey = globalConst->GetHandledErrorString();
|
||||
break;
|
||||
}
|
||||
return JSHandle<JSTaggedValue>(thread, JSTaggedValue(errorKey));
|
||||
return errorKey;
|
||||
}
|
||||
return JSHandle<JSTaggedValue>::Cast(JSTaggedValue::ToString(thread, name));
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ group("ark_js_moduletest") {
|
||||
"dyninstruction",
|
||||
"ecmastringtable",
|
||||
"equal",
|
||||
"errorhelper",
|
||||
"forawaitof",
|
||||
"forin",
|
||||
"fortest",
|
||||
|
18
test/moduletest/errorhelper/BUILD.gn
Normal file
18
test/moduletest/errorhelper/BUILD.gn
Normal file
@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
|
||||
host_moduletest_action("errorhelper") {
|
||||
deps = []
|
||||
}
|
32
test/moduletest/errorhelper/errorhelper.js
Normal file
32
test/moduletest/errorhelper/errorhelper.js
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @tc.name:error_helper
|
||||
* @tc.desc:test error
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
|
||||
const v34 = [2147483648,238049746,1260900180,371215732,1655235460,-65536,-94405277,536870888,-1073741824,-65537];
|
||||
class C37 {
|
||||
}
|
||||
const v40 = new C37();
|
||||
try {
|
||||
v40.constructor(v40, v34, C37, v40);
|
||||
} catch(e45) {
|
||||
const v46 = e45.toString;
|
||||
const v50 = v46.call(v34);
|
||||
print(v50);
|
||||
}
|
14
test/moduletest/errorhelper/expect_output.txt
Normal file
14
test/moduletest/errorhelper/expect_output.txt
Normal file
@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
TypeError
|
Loading…
Reference in New Issue
Block a user