Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define error responses #44

Closed
mmccool opened this issue Aug 3, 2020 · 4 comments
Closed

Define error responses #44

mmccool opened this issue Aug 3, 2020 · 4 comments

Comments

@mmccool
Copy link
Contributor

mmccool commented Aug 3, 2020

For error response, having an array so we can define error responses would be quite useful. Use case supporting w3c/wot-thing-description#617

@farshidtz
Copy link
Member

Not just errors, but also for various success responses with corresponding status codes, content types, and headers.

E.g. for PUTing TD:

{
    "href": "/td/{id}",
    "htv:methodName": "PUT",
    "contentType": "application/td+json",
    "response": [
        {
            "description": "Created new resource",
            "htv:statusCodeValue": 201
        },
        {
            "description": "Updated existing resource",
            "htv:statusCodeValue": 204
        },
        {
            "description": "Invalid input",
            "htv:statusCodeValue": 400,
            "contentType": "application/json"
        },
        {
            "description": "No authentication",
            "htv:statusCodeValue": 401,
            "contentType": "application/json"
        },
        {
            "description": "Insufficient rights",
            "htv:statusCodeValue": 403,
            "contentType": "application/json"
        }
    ]
}

More examples are provided as comments.

@egekorkan
Copy link
Contributor

Also related to w3c/wot-scripting-api#200

I think that the whole working group needs to define error types that are WoT-specific but at the same time mappeable to protocol errors/status codes.

@benfrancis
Copy link
Member

I definitely agree this is needed and in the case of the directory API these error conditions can be documented in the API specification so that clients know what the different errors mean.

If this syntax was generalised to all Thing Descriptions I'm not sure how clients would automatically assign meaning to arbitrary response codes and human-readable descriptions and distinguish between success and error conditions in different protocols. As @egekorkan says it may be necessary to define WoT-specific error codes which can then be mapped onto different underlying protocols.

@farshidtz
Copy link
Member

Discussed in w3c/wot-thing-description#617 and added to TD 1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants