|
| 1 | +/* |
| 2 | + * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 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 | + |
| 17 | +/// Errors produced when validating or querying type definitions. |
| 18 | +#[derive(Debug, thiserror::Error)] |
| 19 | +pub enum InvalidTypeError { |
| 20 | + #[error("Unknown URI: {0}")] |
| 21 | + UnknownUri(String), |
| 22 | + #[error("Duplicate field ID {0} in {1}")] |
| 23 | + DuplicateFieldId(i16, String), |
| 24 | + #[error("Duplicate field name '{0}' in {1}")] |
| 25 | + DuplicateFieldName(String, String), |
| 26 | + #[error("Non-optional field {0} in union {1}")] |
| 27 | + NonOptionalUnionField(i16, String), |
| 28 | + #[error("Duplicate enum value {0} in {1}")] |
| 29 | + DuplicateEnumValue(i32, String), |
| 30 | + #[error("Duplicate enum name '{0}' in {1}")] |
| 31 | + DuplicateEnumName(String, String), |
| 32 | + #[error("Accessed {expected} but TypeRef is {actual}")] |
| 33 | + WrongKind { |
| 34 | + expected: &'static str, |
| 35 | + actual: &'static str, |
| 36 | + }, |
| 37 | + #[error("Duplicate URI: {0}")] |
| 38 | + DuplicateUri(String), |
| 39 | + #[error("Opaque alias target must not be user-defined: {0}")] |
| 40 | + InvalidOpaqueAlias(String), |
| 41 | + #[error("Unresolvable TypeId in {uri}: {detail}")] |
| 42 | + UnresolvableTypeId { uri: String, detail: String }, |
| 43 | + #[error("Empty TypeId")] |
| 44 | + EmptyTypeId, |
| 45 | + #[error("Too many fields ({0}) in {1}, maximum is 65535")] |
| 46 | + TooManyFields(usize, String), |
| 47 | +} |
0 commit comments