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 functions.api module. For example:
Copied!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from functions.api import function, UserFacingError
from ontology_sdk import FoundryClient
from ontology_sdk.ontology.object_sets import AircraftObjectSet
from ontology_sdk.ontology.objects import Aircraft
@function(edits=[Aircraft])
def edit_exactly_five_aircraft(
aircraft_object_set: AircraftObjectSet
) -> list[OntologyEdit]:
aircraft = list(aircraft_object_set)
if not len(aircraft) == 5:
raise UserFacingError(f"Pass in exactly 5 aircraft. Received ${len(aircraft)}.")
... # edit the objects