Improve TD validation error in requestThingDescription#1404
Conversation
|
Unfortunately, it is not possible to wrap an error in TS/JS. |
You should be able to define custom errors. export class ValidationError extends Error {
public constructor(input: ??) {
//...
}
}or did I miss your point? |
|
What I meant was wrapping this error in another error to get a stack trace like in Java |
|
But this still makes me think that there is a TD validation error. The request method should be catched? |
|
Yeah, in the case you described in the issue, the We are not checking the result (e.g., 404 or any other error condition). Unless the URL you provided actually answers with a JSON payload... in that case the error is correct IMHO. |
|
The issue happen in the following code node-wot/packages/core/src/wot-impl.ts Lines 99 to 103 in 3325e12 Line99 returns What I do in my PR is essentially just extending the error (with "TD validation error: ") so that it is clear what the error is about. In this case, the TD is not valid. |
No in this case there is no TD to begin with. The link @relu91 sent makes sense as there is no handling of request not resolving |
|
How do I know whether the result is a TD? We have the In your case, the issue is not that we get a 404 (in such a case you get a 404 message). The issue is that you get a result .. in this case, a JSON |
As I said above, if this is the case, the answer @egekorkan described in the issue is indeed correct. |
|
I seem to be on the wrong track somehow!? 🤷♂️ Can you explain to me what you ask me to do? Or do you want to propose a fix? Yes, we get an array as response, and I do know that this can never be a TD. Hence, I only add to the error message we are getting the information that the error is caused be the TD validation... so that developers better understand what the error is about. |
No, you are correct! I was saying that since we are receiving a valid json (and not a 404 or other error codes like a timeout) the error that we are throwing is correct, we can improve as you are doing here, but I would not even bother (but we can move on if you like). |
|
I will take a closer look at the possible error cases and look also into |
|
Commit 9afaaf2 should add the information needed if an HTTP error happens... |
|
I think this brings up a new issue I think it should be handled by the following part already but it doesn't seem to be the case |
It is not a OAuth error but a generic unauthorized error... I added a special case for it to make the following test happy. |
|
Anything missing? |
revert status code handling code
relu91
left a comment
There was a problem hiding this comment.
LGTM, as discussed in call. Let's merge it.
fixes #1403