Discussion:
exit on api call
(too old to reply)
T
2022-11-29 10:16:43 UTC
Permalink
Hi All,

When I make an API all and my program just exists
without an error or any complaint, is there some
log somewhere that will tell me what went wrong?

Many thanks,
-T
JJ
2022-11-29 23:54:33 UTC
Permalink
Post by T
Hi All,
When I make an API all and my program just exists
without an error or any complaint, is there some
log somewhere that will tell me what went wrong?
Many thanks,
-T
Did you check `GetLastError()`?

Also, some APIs have their own error handling and reporting outside of the
standard Win32 API. So check the API documentation.
T
2022-11-30 02:23:18 UTC
Permalink
Post by JJ
Post by T
Hi All,
When I make an API all and my program just exists
without an error or any complaint, is there some
log somewhere that will tell me what went wrong?
Many thanks,
-T
Did you check `GetLastError()`?
Also, some APIs have their own error handling and reporting outside of the
standard Win32 API. So check the API documentation.
I traced it down to Raku's NativeCall. It
happens when you forget to declare a variable
that is [out] and/or [in/out] as "is rw".

Or use a variable the is a mystery to
NativeCall.

I have written a pm6 for error reporting from
the API calls. There is nothing there.

Makes it pretty difficult to troubleshoot.
JJ
2022-11-30 05:43:43 UTC
Permalink
Post by T
I traced it down to Raku's NativeCall. It
happens when you forget to declare a variable
that is [out] and/or [in/out] as "is rw".
Or use a variable the is a mystery to
NativeCall.
I have written a pm6 for error reporting from
the API calls. There is nothing there.
Makes it pretty difficult to troubleshoot.
Doesn't Raku have its own reporting to tell whether the result of that
"NativeCall" itself has succeeded or not? Such as failure due to mismatched
number of arguments supplied to the API; or if the API is called by
DLL/function name, an error for DLL file is not found or function name is
not found.
T
2022-11-30 07:47:20 UTC
Permalink
Post by JJ
Post by T
I traced it down to Raku's NativeCall. It
happens when you forget to declare a variable
that is [out] and/or [in/out] as "is rw".
Or use a variable the is a mystery to
NativeCall.
I have written a pm6 for error reporting from
the API calls. There is nothing there.
Makes it pretty difficult to troubleshoot.
Doesn't Raku have its own reporting to tell whether the result of that
"NativeCall" itself has succeeded or not? Such as failure due to mismatched
number of arguments supplied to the API; or if the API is called by
DLL/function name, an error for DLL file is not found or function name is
not found.
I does, but it is also not very mature. Consider
it alpha code. It misses things still.
JJ
2022-11-30 21:58:19 UTC
Permalink
Post by T
I does, but it is also not very mature. Consider
it alpha code. It misses things still.
If that's the case, then I don't see any other way than to manually check
the result of the API. e.g. if it creates a window handle, then check
whether the returned window handle value is valid or not. Initialize the
Raku variable which receive the window handle with zero before the API call.

Considering the immature implementation of API call support, calling
`GetLastError()` API may not be reliable since Raku may not preserve the
system's last error code after an API has been called. The "NativeCall" post
housekeeping code may actually overwrite the system's last error code.
Loading...