winter_air/errors.rs
1// Copyright (c) Facebook, Inc. and its affiliates.
2//
3// This source code is licensed under the MIT license found in the
4// LICENSE file in the root directory of this source tree.
5
6use core::fmt;
7
8// ASSERTION ERROR
9// ================================================================================================
10/// Represents an error returned during assertion evaluation.
11#[derive(Debug, PartialEq, Eq)]
12pub enum AssertionError {
13 /// This error occurs when an assertion is evaluated against an execution trace which does not
14 /// contain a column specified by the assertion.
15 TraceWidthTooShort(usize, usize),
16 /// This error occurs when an assertion is evaluated against an execution trace with length
17 /// which is not a power of two.
18 TraceLengthNotPowerOfTwo(usize),
19 /// This error occurs when an assertion is evaluated against an execution trace which does not
20 /// contain a step against which the assertion is placed.
21 TraceLengthTooShort(usize, usize),
22 /// This error occurs when a `Sequence` assertion is placed against an execution trace with
23 /// length which conflicts with the trace length implied by the assertion.
24 TraceLengthNotExact(usize, usize),
25}
26
27impl fmt::Display for AssertionError {
28 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29 match self {
30 Self::TraceWidthTooShort(expected, actual) => {
31 write!(f, "expected trace width to be at least {expected}, but was {actual}")
32 },
33 Self::TraceLengthNotPowerOfTwo(actual) => {
34 write!(f, "expected trace length to be a power of two, but was {actual}")
35 },
36 Self::TraceLengthTooShort(expected, actual) => {
37 write!(f, "expected trace length to be at least {expected}, but was {actual}")
38 },
39 Self::TraceLengthNotExact(expected, actual) => {
40 write!(f, "expected trace length to be exactly {expected}, but was {actual}")
41 },
42 }
43 }
44}
45
46impl core::error::Error for AssertionError {}