1
1
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
// SPDX-License-Identifier: Apache-2.0
3
- use std:: fmt;
4
3
use std:: fs:: File ;
5
4
use std:: io:: { BufReader , Read } ;
6
5
@@ -16,35 +15,22 @@ const THREAD_CATEGORIES: [&str; 3] = ["vmm", "api", "vcpu"];
16
15
const DESERIALIZATION_BYTES_LIMIT : Option < u64 > = Some ( 100_000 ) ;
17
16
18
17
/// Error retrieving seccomp filters.
19
- #[ derive( fmt :: Debug ) ]
18
+ #[ derive( Debug , thiserror :: Error ) ]
20
19
pub enum FilterError {
21
20
/// Filter deserialitaion error.
21
+ #[ error( "Filter deserialization failed: {0}" ) ]
22
22
Deserialization ( DeserializationError ) ,
23
23
/// Invalid thread categories.
24
+ #[ error( "Invalid thread categories: {0}" ) ]
24
25
ThreadCategories ( String ) ,
25
26
/// Missing Thread Category.
27
+ #[ error( "Missing thread category: {0}" ) ]
26
28
MissingThreadCategory ( String ) ,
27
29
/// File open error.
30
+ #[ error( "Filter file open error: {0}" ) ]
28
31
FileOpen ( std:: io:: Error ) ,
29
32
}
30
33
31
- impl fmt:: Display for FilterError {
32
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
33
- use self :: FilterError :: * ;
34
-
35
- match * self {
36
- Deserialization ( ref err) => write ! ( f, "Filter deserialization failed: {}" , err) ,
37
- ThreadCategories ( ref categories) => {
38
- write ! ( f, "Invalid thread categories: {}" , categories)
39
- }
40
- MissingThreadCategory ( ref category) => {
41
- write ! ( f, "Missing thread category: {}" , category)
42
- }
43
- FileOpen ( ref err) => write ! ( f, "Filter file open error: {}" , err) ,
44
- }
45
- }
46
- }
47
-
48
34
/// Seccomp filter configuration.
49
35
pub enum SeccompConfig {
50
36
/// Seccomp filtering disabled.
0 commit comments