1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-06 04:40:23 +00:00

_StatusCode() should give the correct error on invalid handle type

Passing a handle of the invalid type (Ex. TCP) to _StatusCode should
give error 52, but it gies error 9.
This commit is contained in:
Matthew Kilgore 2022-11-20 04:32:35 -05:00
parent 12c9c35db5
commit 445408d95b
9 changed files with 35 additions and 7 deletions

View file

@ -21706,6 +21706,13 @@ int32 func__statusCode(int32 handle) {
}
int real_handle = -(handle + 1);
special_handle_struct *sh = (special_handle_struct *)list_get(special_handles, real_handle);
if (sh->type != special_handle_type::Http) {
error(52);
return -1;
}
int code = libqb_http_get_status_code(real_handle);
if (code == -1) {

View file

@ -15,5 +15,5 @@ Print _StatusCode(h&)
System
errorhand:
PRINT ERR; ERL
PRINT "Error:"; ERR; ", Line:"; _ERRORLINE
RESUME NEXT

View file

@ -1,4 +1,4 @@
5 0
Error: 5 , Line: 6
0
-2
404

View file

@ -13,5 +13,5 @@ Print h&
System
errorhand:
PRINT ERR; ERL
PRINT "Error:"; ERR; ", Line:"; _ERRORLINE
RESUME NEXT

View file

@ -1,4 +1,4 @@
5 0
Error: 5 , Line: 6
0
5 0
Error: 5 , Line: 10
0

View file

@ -7,5 +7,5 @@ Print h&
System
errorhand:
PRINT ERR; ERL
PRINT "Error:"; ERR; ", Line:"; _ERRORLINE
RESUME NEXT

View file

@ -1,2 +1,2 @@
5 0
Error: 5 , Line: 4
0

View file

@ -0,0 +1,18 @@
$Unstable:Http
$Console:Only
ON ERROR GOTO errorhand
h& = _OpenHost("TCP/IP:50000")
' Error, invalid handle type
Print _StatusCode(h&)
' Errors, invalid handle numbers
Print _StatusCode(0)
Print _StatusCode(20)
System
errorhand:
PRINT "Error:"; ERR; ", Line:"; _ERRORLINE
RESUME NEXT

View file

@ -0,0 +1,3 @@
Error: 52 , Line: 8
Error: 52 , Line: 11
Error: 52 , Line: 12