guile-rsv

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 3e3fb9b26f9805a6b5e8df8c1907ac57c6c32983
parent 2d78ec17559f5eaf2cf772ae301bd7d210c70c34
Author: Yuval Langer <yuval.langer@gmail.com>
Date:   Sat, 13 Jan 2024 07:55:20 +0200

Use row and column position as error irritants.

Diffstat:
Mrsv/arbitrary-null.scm | 61+++++++++++++++++++++++++------------------------------------
1 file changed, 25 insertions(+), 36 deletions(-)

diff --git a/rsv/arbitrary-null.scm b/rsv/arbitrary-null.scm @@ -77,11 +77,9 @@ read." (let ((byte (read-u8 port))) (cond ((eof-object? byte) - (error (string-append "Prematurely terminated RSV at row " - (number->string row-count) - " at an offset of " - (number->string column-count) - " from the beginning of the last RSV row."))) + (error "Prematurely terminated RSV at: (row, column)" + row-count + column-count)) ((value-terminator-byte? byte) (values (utf8->string (get-output-bytevector output-field-port)) row-count @@ -91,8 +89,10 @@ read." output-field-port) (loop (+ column-count 1))) (else - (error "Illegal value returned by RSV string reader:" - byte))))))) + (error "Illegal value returned by RSV string reader: (illegal value, row, column)" + byte + row-count + column-count))))))) (define (read-null-value row-count column-count port) ;; `row->scm` had already `peek-u8`-ed and knows that the next @@ -108,21 +108,15 @@ read." ((number? byte) ;; If we've read any other byte following a null byte, we ;; raise an error. - (error (string-append "Expected a Value-Terminator-Byte (#xFF) after" - " a Null Byte (#xFE) at row " - (number->string row-count) - " at an offset of " - (number->string column-count) - " from the beggining of the last RSV row, instead got: " - (number->string byte)))) + (error "Expected a Value-Terminator-Byte (#xFF) after a Null Byte (#xFE), instead got: (unexpected byte, row, column)" + byte + row-count + column-count)) (else - (error (string-append "Expected a Value-Terminator-Byte (#xFF) after" - " a Null Byte (#xFE) at row " - (number->string row-count) - " at an offset of " - (number->string column-count) - " from the beggining of the last RSV row, instead got illegal value:") - byte))))) + (error "Expected a Value-Terminator-Byte (#xFF) after a Null Byte (#xFE), instead got illegal value: (illegal value, row, column)" + byte + row-count + column-count))))) (define (read-rsv-row row-count column-count port) (let loop ((row '()) @@ -130,11 +124,9 @@ read." (column-count column-count)) (let ((byte (peek-u8 port))) (cond ((eof-object? byte) - (error (string-append "Prematurely terminated RSV at row " - (number->string row-count) - " at an offset of " - (number->string column-count) - " from the beginning of the last RSV row."))) + (error "Prematurely terminated RSV: (row, column)" + row-count + column-count)) ((row-terminator-byte? byte) ;; End of row. (read-u8 port) ;; Remove row terminator. (values (reverse row) @@ -166,12 +158,10 @@ read." new-column-count))) (else - (error (string-append "Illegal value returned in read-rsv-row when reading RSV row " - (number->string row-count) - " at offset of " - (number->string column-count) - " bytes by row reader:") - byte)))))) + (error "Illegal value returned in read-rsv-row: (illegal value, row, column)" + byte + row-count + column-count)))))) (define (read-rsv port) (let loop ((rows '()) @@ -190,7 +180,6 @@ read." new-column-count))) (else - (error (string-append "Illegal value returned when reading RSV row " - (number->string row-count) - ":") - byte)))))))) + (error "Illegal value returned when reading RSV row: (illegal value, row)" + byte + row-count))))))))