!4284 bugfix:errorName

Merge pull request !4284 from yaochaonan/error
This commit is contained in:
openharmony_ci 2023-06-21 06:02:13 +00:00 committed by Gitee
commit 32443bf5ff
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 76 additions and 11 deletions

View File

@ -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));
}

View File

@ -42,6 +42,7 @@ group("ark_js_moduletest") {
"dyninstruction",
"ecmastringtable",
"equal",
"errorhelper",
"forawaitof",
"forin",
"fortest",

View 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 = []
}

View 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);
}

View 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