Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
HttpStatus
n/a
0 / 0
n/a
0 / 0
0
n/a
0 / 0
1<?php
2/**
3 * WikiLambda utility file for error codes
4 *
5 * @file
6 * @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt
7 * @license MIT
8 */
9
10namespace MediaWiki\Extension\WikiLambda;
11
12class HttpStatus {
13    // 2xx Success
14    public const OK = 200;
15    public const CREATED = 201;
16    public const ACCEPTED = 202;
17    public const NO_CONTENT = 204;
18
19    // 4xx Client Errors
20    public const BAD_REQUEST = 400;
21    public const UNAUTHORIZED = 401;
22    public const FORBIDDEN = 403;
23    public const NOT_FOUND = 404;
24    public const REQUEST_TIMEOUT = 408;
25    public const CONFLICT = 409;
26    public const UNPROCESSABLE_ENTITY = 422;
27    public const TOO_MANY_REQUESTS = 429;
28
29    // 5xx Server Errors
30    public const INTERNAL_SERVER_ERROR = 500;
31    public const NOT_IMPLEMENTED = 501;
32    public const BAD_GATEWAY = 502;
33    public const SERVICE_UNAVAILABLE = 503;
34    public const GATEWAY_TIMEOUT = 504;
35
36    /**
37     * Status codes for a function call that failed because the content is wrong: either the
38     * request itself, or one of the ZObjects that it uses. The same call keeps giving the same
39     * error until an editor changes the content, because nothing else can make it succeed.
40     *
41     * This is the only property that this list gives you. Callers decide what to do with it;
42     * e.g. they can cache the failure for longer, or log it more quietly than a failure that
43     * a retry can clear. This list says nothing about the other status codes: a code that is
44     * not here can be a temporary failure, but it can also be a different permanent one.
45     *
46     * The orchestrator sets its status codes from the Z5/Error type; see the mappings in
47     * function-schemata's `test_data/errors/http_status_mappings.yaml`.
48     */
49    public const CONTENT_ERROR_CODES = [
50        // e.g. Z518/ZObject type mismatch
51        self::BAD_REQUEST,
52        // e.g. Z504/ID not found
53        self::NOT_FOUND,
54        // e.g. Z513/Resolved object without Z2K2
55        self::CONFLICT,
56        // e.g. Z500/Unspecified error
57        self::UNPROCESSABLE_ENTITY,
58    ];
59}