Skip to content

Commit 43c2563

Browse files
committed
[PERF] formula functions: replace thrown errors with a return error
Replace existring "throw new Error.." by "return new Error.." in formula compute functions closes #6184 Task: 4671645 X-original-commit: 13a5ead Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
1 parent 4cf7f95 commit 43c2563

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/functions/module_filter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ export const UNIQUE = {
308308
range: Arg = { value: "" },
309309
byColumn: Maybe<FunctionResultObject>,
310310
exactlyOnce: Maybe<FunctionResultObject>
311-
): Matrix<FunctionResultObject> {
311+
) {
312312
if (!isMatrix(range)) {
313313
return [[range]];
314314
}
@@ -339,7 +339,7 @@ export const UNIQUE = {
339339
result.push(row.data);
340340
}
341341

342-
if (!result.length) throw new EvaluationError(_t("No unique values found"));
342+
if (!result.length) return new EvaluationError(_t("No unique values found"));
343343

344344
return _byColumn ? result : transposeMatrix(result);
345345
},

src/functions/module_lookup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ export const OFFSET = {
949949

950950
const _cellReference = cellReference?.value;
951951
if (!_cellReference) {
952-
throw new Error(
952+
return new EvaluationError(
953953
"In this context, the function OFFSET needs to have a cell or range in parameter."
954954
);
955955
}

src/functions/module_statistical.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ export const RANK: AddFunctionDescription = {
12651265
value: Maybe<FunctionResultObject>,
12661266
data: Matrix<FunctionResultObject>,
12671267
isAscending: Maybe<FunctionResultObject> = { value: false }
1268-
): number {
1268+
) {
12691269
const _isAscending = toBoolean(isAscending);
12701270
const _value = toNumber(value, this.locale);
12711271
let rank = 1;
@@ -1284,7 +1284,7 @@ export const RANK: AddFunctionDescription = {
12841284
}
12851285
}
12861286
if (!found) {
1287-
throw new NotAvailableError(_t("Value not found in the given data."));
1287+
return new NotAvailableError(_t("Value not found in the given data."));
12881288
}
12891289
return rank;
12901290
},

0 commit comments

Comments
 (0)