OpenComputers icon indicating copy to clipboard operation
OpenComputers copied to clipboard

Internet API Throws Exception for HTTP Error Response

Open andrewlalis opened this issue 5 years ago • 0 comments

I'm trying to use an API running on localhost, but when I attempt to send a malformed payload to one of its endpoints, there is no clean way for me to handle that scenario programmatically in the ingame script, because attempting to iterate over the request handle throws the following error: Server returned HTTP response code: 400 for URL: ..., and getmetatable(handle).__index.response() simply returns nil so I am unable to check for certain response codes there either.

Now, I'm not familiar with Scala, but I believe that it is caused by the call() method here https://github.com/MightyPirates/OpenComputers/blob/master-MC1.12/src/main/scala/li/cil/oc/server/component/InternetCard.scala which simply takes any exception thrown by the HTTP request and throws it further, despite the fact that 400's are probably thrown as an exception by whatever proxy library you're using.

andrewlalis avatar Jan 03 '21 14:01 andrewlalis