error: Add 'sub-type' field to '&netlink-decoder-error' and use it.

Ludovic Court??sTue May 23 20:46:43+0200 2023

6b09d93

error: Add 'sub-type' field to '&netlink-decoder-error' and use it. * netlink/error.scm (&netlink-decoder-error)[sub-type]: New field. * netlink/data.scm (get-next-deserialize, get-current-deserialize): Fill it out. Signed-off-by: Julien Lepiller <julien@lepiller.eu>

netlink/data.scm

5151
  (match (assoc-ref decoder current-type)
5252
    ((_ . type-alist)
5353
     (or (assoc-ref type-alist target-type)
54-
         (assoc-ref type-alist 'default)))
54+
         (assoc-ref type-alist 'default)
55+
         (raise (condition (&netlink-decoder-error
56+
                            (type current-type)
57+
                            (sub-type target-type))))))
5558
    (#f (raise (condition (&netlink-decoder-error
56-
                            (type current-type)))))))
57-
  
59+
                           (type current-type)
60+
                           (sub-type target-type)))))))
61+
5862
(define (get-current-deserialize decoder current-type)
5963
  (match (assoc-ref decoder current-type)
6064
    ((current-deserialize . _) current-deserialize)
6165
    (#f (raise (condition (&netlink-decoder-error
62-
                            (type current-type)))))))
66+
                            (type current-type)
67+
                            (sub-type #f)))))))
6368
6469
(define (deserialize type decoder bv pos)
6570
  (let ((deserialize (get-current-deserialize decoder type)))

netlink/error.scm

2323
            &netlink-decoder-error
2424
            netlink-decoder-error?
2525
            netlink-decoder-error-type
26+
            netlink-decoder-error-sub-type
2627
2728
            &netlink-family-error
2829
            netlink-family-error?

5758
;; No decoder for type
5859
(define-condition-type &netlink-decoder-error &netlink-error
5960
  netlink-decoder-error?
60-
  (type netlink-decoder-error-type))
61+
  (type netlink-decoder-error-type)
62+
  (sub-type netlink-decoder-error-sub-type))
6163
6264
;; Unknown protocol family
6365
(define-condition-type &netlink-family-error &netlink-error