[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-scheme] 216/324: mq: Inject errors if no appropriate message han
From: |
gnunet |
Subject: |
[gnunet-scheme] 216/324: mq: Inject errors if no appropriate message handler exists. |
Date: |
Tue, 21 Sep 2021 13:24:16 +0200 |
This is an automated email from the git hooks/post-receive script.
maxime-devos pushed a commit to branch master
in repository gnunet-scheme.
commit deee34490d251cbfb19d6a9c6c4b9d81131250ac
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Tue Aug 31 19:15:19 2021 +0200
mq: Inject errors if no appropriate message handler exists.
* gnu/gnunet/mq.scm (inject-message!): Inject logic:no-handler error
when the handler does not exist.
* tests/mq.scm ("no applicable message handler error"): New test.
* README.org (List of errors): Document it.
* doc/scheme-gnunet.tm (logic:no-handler): Likewise.
---
README.org | 2 ++
doc/scheme-gnunet.tm | 6 ++++++
gnu/gnunet/mq.scm | 9 +++------
tests/mq.scm | 14 ++++++++++++++
4 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/README.org b/README.org
index a5b4c98..790c7be 100644
--- a/README.org
+++ b/README.org
@@ -133,6 +133,8 @@
Injected by (gnu gnunet mq-impl stream).
Input errors (decoding)
+ + logic:no-handler type . rest
+ No handler for received message type (rest is currently unspecified)
+ TODO verification failed, unknown message type
** Configuration :test:good:
+ gnu/gnunet/config/parser.scm: Parse configuration files.
diff --git a/doc/scheme-gnunet.tm b/doc/scheme-gnunet.tm
index 2869c26..ec47153 100644
--- a/doc/scheme-gnunet.tm
+++ b/doc/scheme-gnunet.tm
@@ -421,6 +421,12 @@
are <scm|#false> instead.<space|1em>This can only happen if the server or
connection to the server is buggy.>
+ <\explain>
+ <scm|logic:no-handler> <var|type> . <var|rest>
+ </explain|The received message of type <var|type> (as an integer) does not
+ have a corresponding message handler.<space|1em><var|rest> is currently
+ unspecified.>
+
<todo|errors for no message handler and malformed messages>
Consider automatically reconnecting after
diff --git a/gnu/gnunet/mq.scm b/gnu/gnunet/mq.scm
index e53fdee..deaca3f 100644
--- a/gnu/gnunet/mq.scm
+++ b/gnu/gnunet/mq.scm
@@ -187,10 +187,8 @@ messages must be sent in-order (TODO really received
in-order?)."
for the type of the message @var{mq} in the message queue var{mq}
with the message @var{message}. In case the message is malformed
(according to the message handler), inject a @code{&malformed-message}
-error instead.
-
-(TODO). In case no appropriate message handler exists,
-inject a ??? instead.
+error instead (TODO). In case no appropriate message handler exists,
+inject a @code{logic:no-handler} error instead.
It is an error for @var{message} to be so small it doesn't have
a @code{/:message-header}. Likewise, it is also an error for the
@@ -222,8 +220,7 @@ of message queues."
(message-queue-handlers mq)
type))
(? (not handler)
- ;; TODO: error handling
- (inject-error! handler ???))
+ (inject-error! mq 'logic:no-handler type))
(? (not (verify-message? handler message))
;; TODO: error handling
(inject-error! handler ???))) ; malformed message
diff --git a/tests/mq.scm b/tests/mq.scm
index 987dfa8..82f2f82 100644
--- a/tests/mq.scm
+++ b/tests/mq.scm
@@ -33,6 +33,7 @@
(srfi srfi-43)
(srfi srfi-64)
(srfi srfi-111)
+ (ice-9 match)
((rnrs base) #:select (assert mod))
((rnrs exceptions) #:select (guard))
((rnrs conditions) #:select (condition-who))
@@ -45,6 +46,7 @@
(gnu gnunet mq prio-prefs2)
(gnu gnunet util struct)
(gnu gnunet utils bv-slice)
+ (gnu gnunet utils hat-let)
((gnu extractor enum)
#:select (symbol-value value->index))
(gnu gnunet message protocols)
@@ -617,6 +619,18 @@ with @code{x}."
(inject-message! mq s)
#f)))))
+(test-assert "no applicable message handler error"
+ (let^ ((! errored? #f)
+ (! slice (bv-slice/read-write #vu8(0 4 0 0)))
+ (! (error-handler . e)
+ (match e
+ ('(logic:no-handler 0)
+ (assert (not errored?))
+ (set! errored? #t)
+ (values))))
+ (! mq (make-message-queue no-handlers error-handler #f)))
+ (inject-message! mq slice)
+ errored?))
;; TODO: what if the message is (otherwise) malformed?
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet-scheme] 215/324: tests/mq-stream: Use 'message-handler' macro., (continued)
- [gnunet-scheme] 215/324: tests/mq-stream: Use 'message-handler' macro., gnunet, 2021/09/21
- [gnunet-scheme] 218/324: mq-impl/stream: Name the reader and writer thunks., gnunet, 2021/09/21
- [gnunet-scheme] 208/324: tests/mq-stream: Don't assume setvbuf returns anything., gnunet, 2021/09/21
- [gnunet-scheme] 212/324: mq/handler: Define a macro for constructing handlers., gnunet, 2021/09/21
- [gnunet-scheme] 220/324: mq-impl/stream: Extract code to be shared with connect/fibers., gnunet, 2021/09/21
- [gnunet-scheme] 226/324: doc: Generate PDF and HTML documentation, gnunet, 2021/09/21
- [gnunet-scheme] 227/324: mq: Remove TODOs about hypothetical &malformed-message., gnunet, 2021/09/21
- [gnunet-scheme] 229/324: guix: Import missing module., gnunet, 2021/09/21
- [gnunet-scheme] 194/324: mq-impl/stream: Eliminate atomic box., gnunet, 2021/09/21
- [gnunet-scheme] 191/324: doc: Document message queue error handling., gnunet, 2021/09/21
- [gnunet-scheme] 216/324: mq: Inject errors if no appropriate message handler exists.,
gnunet <=
- [gnunet-scheme] 190/324: Correct XXX and TODO on input:regular-end-of-file., gnunet, 2021/09/21
- [gnunet-scheme] 196/324: mq-impl/stream: Stop all fibers when EOF is reached (part 1)., gnunet, 2021/09/21
- [gnunet-scheme] 201/324: tests/mq-stream: Make test more strict., gnunet, 2021/09/21
- [gnunet-scheme] 204/324: mq-impl/stream: Document implementation pitfall., gnunet, 2021/09/21
- [gnunet-scheme] 214/324: tests/mq: Use 'message-handler' macro., gnunet, 2021/09/21
- [gnunet-scheme] 217/324: tests/mq: Spam the log less., gnunet, 2021/09/21
- [gnunet-scheme] 233/324: doc: Document the message type database a little., gnunet, 2021/09/21
- [gnunet-scheme] 232/324: doc: Partially document handler procedures and interposers., gnunet, 2021/09/21
- [gnunet-scheme] 239/324: tests/network-size: Don't let the GC close port., gnunet, 2021/09/21
- [gnunet-scheme] 241/324: nse/client: Add a 'disconnected' callback., gnunet, 2021/09/21