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")
13 ;;; Protocol buffers conditions
15 (define-condition undefined-type (simple-error)
16 ((type-name :type string
17 :reader error-type-name
19 (:documentation "Indicates that a schema references a type which has not been defined.")
20 (:default-initargs :format-control "Undefined type:")
21 (:report (lambda (condition stream)
22 (format stream "~? ~S"
23 (simple-condition-format-control condition)
24 (simple-condition-format-arguments condition)
25 (error-type-name condition)))))
27 (define-condition undefined-field-type (undefined-type)
28 ((field :type protobuf-field
31 (:documentation "Indicates that a schema contains a message with a field whose type is not a
32 primitive type and is not a known message (or extend) or enum.")
33 (:report (lambda (condition stream)
34 (format stream "~? Field ~A in message ~A has unknown type ~A"
35 (simple-condition-format-control condition)
36 (simple-condition-format-arguments condition)
37 (error-field condition)
38 (proto-parent (error-field condition))
39 (error-type-name condition)))))
41 ;; The serializers use this a lot, so wrap it up
42 (defun undefined-field-type (format-control object type field)
43 (error 'undefined-field-type
44 :format-control format-control
45 :format-arguments (list object)
46 :type-name (prin1-to-string type)
49 (define-condition undefined-method-type (undefined-type)
50 ((method :type protobuf-method
56 :documentation "Description of which type referenced by the method is undefined."))
57 (:documentation "Superclass for `undefined-type' errors related to a `protobuf-method'. Indicates
58 that a schema contains a service with a method whose input, output, or stream
59 type is not a known message (or extend).")
60 (:report (lambda (condition stream)
61 (format stream "~? ~A type for RPC ~A in service ~A has unknown type ~A"
62 (simple-condition-format-control condition)
63 (simple-condition-format-arguments condition)
64 (error-where condition)
65 (error-method condition)
66 (proto-parent (error-method condition))
67 (error-type-name condition)))))
69 (define-condition undefined-input-type (undefined-method-type)
71 (:default-initargs :where "Input"))
73 (define-condition undefined-output-type (undefined-method-type)
75 (:default-initargs :where "Output"))
77 (define-condition undefined-stream-type (undefined-method-type)
79 (:default-initargs :where "Stream"))