1 //
2 // ========================================================================
3 // Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
8 //
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
11 //
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
14 //
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
17 //
18
19 package org.eclipse.jetty.http2;
20
21 import java.util.HashMap;
22 import java.util.Map;
23
24 public enum ErrorCode
25 {
26 NO_ERROR(0),
27 PROTOCOL_ERROR(1),
28 INTERNAL_ERROR(2),
29 FLOW_CONTROL_ERROR(3),
30 SETTINGS_TIMEOUT_ERROR(4),
31 STREAM_CLOSED_ERROR(5),
32 FRAME_SIZE_ERROR(6),
33 REFUSED_STREAM_ERROR(7),
34 CANCEL_STREAM_ERROR(8),
35 COMPRESSION_ERROR(9),
36 HTTP_CONNECT_ERROR(10),
37 ENHANCE_YOUR_CALM_ERROR(11),
38 INADEQUATE_SECURITY_ERROR(12),
39 HTTP_1_1_REQUIRED_ERROR(13);
40
41 public final int code;
42
43 private ErrorCode(int code)
44 {
45 this.code = code;
46 Codes.codes.put(code, this);
47 }
48
49 public static ErrorCode from(int error)
50 {
51 return Codes.codes.get(error);
52 }
53
54 private static class Codes
55 {
56 private static final Map<Integer, ErrorCode> codes = new HashMap<>();
57 }
58 }