When running Functions in other parts of the platform, such as Workshop or Actions, you may want to throw an error with a detailed message. To do so, throw a UserFacingError from the @foundry/functions-api package. For example:
Copied!
1
2
3
4
5
6
7
8
9
10
11
import { Edits, OntologyEditFunction, UserFacingError } from "@foundry/functions-api";
import { Employee } from "@foundry/ontology-api";
@Edits(Employee)
@OntologyEditFunction()
public editExactlyFiveEmployees(employees: Employee[]): void {
if (employees.length != 5) {
throw new UserFacingError(`Pass in exactly 5 employees. Received ${employees.length}.`);
}
...
}