๐ Key Return Values
After calling an operation with activate
, Uniface provides return values that help you assess the result and detect any errors.
$status
โ The Main Return Value
-
> 0
: Successful execution, value returned by the operation. -
0
: No value assigned or noreturn
statement present. -
< 0
: An error occurred; details are in$procerror
. -
9
: User exited the form with^ACCEPT
. -
10
: User exited the form with^QUIT
.
Code Example:
activate "MyCpt".do_it()
if ($status < 0)
message "Error: " + $procerror
endif
๐จ Error Handling with $procerror
If an error occurs, $procerror
contains a specific error code. The most important codes:
Error Code | Meaning |
---|---|
-50 | Component not found |
-59 | Operation not defined |
-1122 | Wrong number of arguments |
-155 | Instance could not be created |
... | See documentation for more |
Code Example:
activate "MyCpt".do_it()
if ($status < 0)
selectcase $procerror
case -50
message "Component not found!"
case -59
message "Operation does not exist!"
case -1122
message "Wrong number of arguments!"
case else
message "Unknown error: " + $procerror
endselectcase
endif
๐งฐ Best Practices
-
Always check
$status
and$procerror
: Evaluate these values after every activate call. - Provide meaningful error messages: Use error codes to give targeted feedback.
- Avoid negative return values: In your own operations, avoid returning negative values, as Uniface interprets them as errors.
๐ต๏ธโโ๏ธ Common Pitfalls
- Wrong arguments: Number or type does not match the operationโs parameters.
- Incorrect instance or operation name: Typos lead to -50 or -59.
-
Asynchronous calls: No OUT/INOUT parameters and no return value with
/async
.
๐ Example: Robust Error Handling
Code Example:
activate "MyService".calculate(100, 200)
if ($status < 0)
message "Error during call: " + $procerror
return
endif
message "Calculation successful! Result: " + $status
This post is based on the official Uniface 10.4 documentation and was created with AI support. For details, see the original documentation.
Top comments (0)