blob: 7daa80627aac85480c0172df410ee6f3c98a490c [file] [log] [blame]
Daniele Morodbcffda2021-06-11 16:41:48 +02001/*
2 * Copyright 2021-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.net.behaviour.upf;
18
19/**
20 * An exception indicating a an error happened in the UPF programmable behaviour.
21 * Possible errors include the attempted insertion of a malformed flow rule, the
22 * reading or writing of an out-of-bounds counter cell, the deletion of a non-existent
23 * flow rule, and the attempted insertion of a flow rule into a full table.
24 */
25public class UpfProgrammableException extends Exception {
26 private final Type type;
27
28 public enum Type {
29 /**
30 * The UpfProgrammable did not provide a specific exception type.
31 */
32 UNKNOWN,
33 /**
34 * The target table is at capacity.
35 */
36 TABLE_EXHAUSTED,
37 /**
38 * A provided counter cell index was out of range.
39 */
40 COUNTER_INDEX_OUT_OF_RANGE,
41 /**
42 * The UpfProgrammable implementation doesn't support the operation.
43 */
44 UNSUPPORTED_OPERATION
45 }
46
47 /**
48 * Creates a new exception for the given message.
49 *
50 * @param message message
51 */
52 public UpfProgrammableException(String message) {
53 super(message);
54 this.type = Type.UNKNOWN;
55 }
56
57 /**
58 * Creates a new exception for the given message and type.
59 *
60 * @param message exception message
61 * @param type exception type
62 */
63 public UpfProgrammableException(String message, Type type) {
64 super(message);
65 this.type = type;
66 }
67
68 /**
69 * Get the type of the exception.
70 *
71 * @return exception type
72 */
73 public Type getType() {
74 return type;
75 }
76}