mirror of
https://github.com/rust-lang/cargo
synced 2024-08-25 10:35:53 +00:00
Auto merge of #10860 - Eh2406:4xxDocs, r=ehuss
servers should use 404 Clarify the docs in lieu of our conversation at https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Sparse.20Registry.20Errors
This commit is contained in:
commit
289ab53313
|
@ -320,9 +320,10 @@ visit the registry's website to obtain a token, and Cargo can store the token
|
|||
using the [`cargo login`] command, or by passing the token on the
|
||||
command-line.
|
||||
|
||||
Responses use a 200 response code for both success and errors. Cargo looks at
|
||||
the JSON response to determine if there was success or failure. Failure
|
||||
responses have a JSON object with the following structure:
|
||||
Responses use the 200 response code for success.
|
||||
Errors should use an appropriate response code, such as 404.
|
||||
Failure
|
||||
responses should have a JSON object with the following structure:
|
||||
|
||||
```javascript
|
||||
{
|
||||
|
@ -336,10 +337,10 @@ responses have a JSON object with the following structure:
|
|||
}
|
||||
```
|
||||
|
||||
Servers may also respond with a 404 response code to indicate the requested
|
||||
resource is not found (for example, an unknown crate name). However, using a
|
||||
200 response with an `errors` object allows a registry to provide a more
|
||||
detailed error message if desired.
|
||||
If the response has this structure Cargo will display the detailed message to the user, even if the response code is 200.
|
||||
If the response code indicates an error and the content does not have this structure, Cargo will display to the user a
|
||||
message intended to help debugging the server error. A server returning an `errors` object allows a registry to provide a more
|
||||
detailed or user-centric error message.
|
||||
|
||||
For backwards compatibility, servers should ignore any unexpected query
|
||||
parameters or JSON fields. If a JSON field is missing, it should be assumed to
|
||||
|
|
Loading…
Reference in a new issue