error.scm
1 | ;;;; This file is part of Guile Netlink |
2 | ;;;; |
3 | ;;;; Copyright (C) 2021 Julien Lepiller <julien@lepiller.eu> |
4 | ;;;; |
5 | ;;;; This library is free software: you can redistribute it and/or modify |
6 | ;;;; it under the terms of the GNU General Public License as published by |
7 | ;;;; the Free Software Foundation, either version 3 of the License, or |
8 | ;;;; (at your option) any later version. |
9 | ;;;; |
10 | ;;;; This library is distributed in the hope that it will be useful, |
11 | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | ;;;; GNU General Public License for more details. |
14 | ;;;; |
15 | ;;;; You should have received a copy of the GNU General Public License |
16 | ;;;; along with this library. If not, see <https://www.gnu.org/licenses/>. |
17 | |
18 | (define-module (netlink error) |
19 | #:use-module (srfi srfi-35) |
20 | #:export (&netlink-error |
21 | netlink-error? |
22 | |
23 | &netlink-decoder-error |
24 | netlink-decoder-error? |
25 | netlink-decoder-error-type |
26 | netlink-decoder-error-sub-type |
27 | |
28 | &netlink-family-error |
29 | netlink-family-error? |
30 | netlink-family-error-family |
31 | |
32 | &netlink-cidr-error |
33 | netlink-cidr-error? |
34 | netlink-cidr-error-str |
35 | |
36 | &netlink-message-error |
37 | netlink-message-error? |
38 | |
39 | &netlink-answer-too-big-error |
40 | netlink-answer-too-big-error? |
41 | netlink-answer-too-big-error-size |
42 | |
43 | &netlink-message-type-error |
44 | netlink-message-type-error? |
45 | netlink-message-type-error-message |
46 | |
47 | &netlink-device-error |
48 | netlink-device-error? |
49 | netlink-device-error-device |
50 | |
51 | &netlink-response-error |
52 | netlink-response-error? |
53 | netlink-response-error-errno)) |
54 | |
55 | (define-condition-type &netlink-error &error |
56 | netlink-error?) |
57 | |
58 | ;; No decoder for type |
59 | (define-condition-type &netlink-decoder-error &netlink-error |
60 | netlink-decoder-error? |
61 | (type netlink-decoder-error-type) |
62 | (sub-type netlink-decoder-error-sub-type)) |
63 | |
64 | ;; Unknown protocol family |
65 | (define-condition-type &netlink-family-error &netlink-error |
66 | netlink-family-error? |
67 | (family netlink-family-error-family)) |
68 | |
69 | ;; Unknow CIDR notation |
70 | (define-condition-type &netlink-cidr-error &netlink-error |
71 | netlink-cidr-error? |
72 | (str netlink-cidr-error-str)) |
73 | |
74 | ;; Error when handling messages |
75 | (define-condition-type &netlink-message-error &netlink-error |
76 | netlink-message-error?) |
77 | |
78 | ;; Answer is too big to handle |
79 | (define-condition-type &netlink-answer-too-big-error &netlink-message-error |
80 | netlink-answer-too-big-error? |
81 | (size netlink-answer-too-big-error-size)) |
82 | |
83 | ;; Attempting to send a message that is not a message object |
84 | (define-condition-type &netlink-message-type-error &netlink-message-error |
85 | netlink-message-type-error? |
86 | (message netlink-message-type-error-message)) |
87 | |
88 | ;; No such device |
89 | (define-condition-type &netlink-device-error &netlink-error |
90 | netlink-device-error? |
91 | (device netlink-device-error-device)) |
92 | |
93 | ;; Got an answer, but it is an error message |
94 | (define-condition-type &netlink-response-error &netlink-error |
95 | netlink-response-error? |
96 | (errno netlink-response-error-errno)) |
97 |