1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 ;;; Free Software published under an MIT-like license. See LICENSE ;;;
5 ;;; Copyright (c) 2012 Google, Inc. All rights reserved. ;;;
7 ;;; Original author: Ben Wagner ;;;
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11 (in-package "PROTO-IMPL")
14 ;;; Protocol buffers conditions
16 (define-condition undefined-type (simple-error)
17 ((type-name :type string
18 :reader error-type-name
20 (:documentation "Indicates that a schema references a type which has not been defined.")
21 (:default-initargs :format-control "Undefined type:")
22 (:report (lambda (condition stream)
23 (format stream "~? ~S"
24 (simple-condition-format-control condition)
25 (simple-condition-format-arguments condition)
26 (error-type-name condition)))))
28 (define-condition undefined-field-type (undefined-type)
29 ((field :type protobuf-field
32 (:documentation "Indicates that a schema contains a message with a field whose type is not a
33 primitive type and is not a known message (or extend) or enum.")
34 (:report (lambda (condition stream)
35 (format stream "~? Field ~A in message ~A has unknown type ~A"
36 (simple-condition-format-control condition)
37 (simple-condition-format-arguments condition)
38 (error-field condition)
39 (proto-parent (error-field condition))
40 (error-type-name condition)))))
42 ;; The serializers use this a lot, so wrap it up
43 (defun undefined-field-type (format-control object type field)
44 (error 'undefined-field-type
45 :format-control format-control
46 :format-arguments (list object)
47 :type-name (prin1-to-string type)
50 (define-condition undefined-method-type (undefined-type)
51 ((method :type protobuf-method
57 :documentation "Description of which type referenced by the method is undefined."))
58 (:documentation "Superclass for `undefined-type' errors related to a `protobuf-method'. Indicates
59 that a schema contains a service with a method whose input, output, or stream
60 type is not a known message (or extend).")
61 (:report (lambda (condition stream)
62 (format stream "~? ~A type for RPC ~A in service ~A has unknown type ~A"
63 (simple-condition-format-control condition)
64 (simple-condition-format-arguments condition)
65 (error-where condition)
66 (error-method condition)
67 (proto-parent (error-method condition))
68 (error-type-name condition)))))
70 (define-condition undefined-input-type (undefined-method-type)
72 (:default-initargs :where "Input"))
74 (define-condition undefined-output-type (undefined-method-type)
76 (:default-initargs :where "Output"))
78 (define-condition undefined-stream-type (undefined-method-type)
80 (:default-initargs :where "Stream"))