bind/bytecode_encoder/
error.rs

1// Copyright 2019 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use crate::errors::UserError;
6use crate::parser::bind_library;
7use std::fmt;
8use thiserror::Error;
9
10#[derive(Debug, Error, Clone, PartialEq)]
11pub enum BindRulesEncodeError {
12    InvalidStringLength(String),
13    UnsupportedSymbol,
14    IntegerOutOfRange,
15    MismatchValueTypes(bind_library::ValueType, bind_library::ValueType),
16    IncorrectTypesInValueComparison,
17    DuplicateLabel(u32),
18    MissingLabel(u32),
19    InvalidGotoLocation(u32),
20    JumpOffsetOutOfRange(u32),
21    MatchNotSupported,
22    MissingCompositeDeviceName,
23    MissingCompositeNodeName,
24    DuplicateCompositeNodeName(String),
25    MissingAstLocation,
26}
27
28impl fmt::Display for BindRulesEncodeError {
29    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30        write!(f, "{}", UserError::from(self.clone()))
31    }
32}