The returnError function in UserSpice is a custom function used to return an error response in JSON format and terminate the script execution.
Location
users/helpers/us_helpers.php
Parameters
#
Parameter
Data Type
Required
Description
1
$errorMsg
string
Yes
The error message to be included in the response.
Further Documentation:
$errorMsg = "An error occurred.";
returnError($errorMsg);
In the example above, the returnError function is called with the $errorMsg variable as the argument. The function constructs an error response in JSON format with the provided error message. It then exits the script execution by calling exit() function with the JSON-encoded response.
Note that the returnError function is typically used when encountering an error situation to provide a standardized error response format and halt the script execution.