guile-netlink/netlink/error.scm

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
27
            &netlink-family-error
28
            netlink-family-error?
29
            netlink-family-error-family
30
31
            &netlink-cidr-error
32
            netlink-cidr-error?
33
            netlink-cidr-error-str
34
35
            &netlink-message-error
36
            netlink-message-error?
37
38
            &netlink-answer-too-big-error
39
            netlink-answer-too-big-error?
40
            netlink-answer-too-big-error-size
41
42
            &netlink-message-type-error
43
            netlink-message-type-error?
44
            netlink-message-type-error-message
45
46
            &netlink-device-error
47
            netlink-device-error?
48
            netlink-device-error-device
49
50
            &netlink-response-error
51
            netlink-response-error?
52
            netlink-response-error-errno))
53
54
(define-condition-type &netlink-error &error
55
  netlink-error?)
56
57
;; No decoder for type
58
(define-condition-type &netlink-decoder-error &netlink-error
59
  netlink-decoder-error?
60
  (type netlink-decoder-error-type))
61
62
;; Unknown protocol family
63
(define-condition-type &netlink-family-error &netlink-error
64
  netlink-family-error?
65
  (family netlink-family-error-family))
66
67
;; Unknow CIDR notation
68
(define-condition-type &netlink-cidr-error &netlink-error
69
  netlink-cidr-error?
70
  (str netlink-cidr-error-str))
71
72
;; Error when handling messages
73
(define-condition-type &netlink-message-error &netlink-error
74
  netlink-message-error?)
75
76
;; Answer is too big to handle
77
(define-condition-type &netlink-answer-too-big-error &netlink-message-error
78
  netlink-answer-too-big-error?
79
  (size netlink-answer-too-big-error-size))
80
81
;; Attempting to send a message that is not a message object
82
(define-condition-type &netlink-message-type-error &netlink-message-error
83
  netlink-message-type-error?
84
  (message netlink-message-type-error-message))
85
86
;; No such device
87
(define-condition-type &netlink-device-error &netlink-error
88
  netlink-device-error?
89
  (device netlink-device-error-device))
90
91
;; Got an answer, but it is an error message
92
(define-condition-type &netlink-response-error &netlink-error
93
  netlink-response-error?
94
  (errno netlink-response-error-errno))
95