Dolda2000 GitWeb
/
lisp-utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f8eaaa2
)
Signal an error when a named codec could not be found.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Thu, 11 Mar 2010 20:07:47 +0000
(21:07 +0100)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Thu, 11 Mar 2010 20:07:47 +0000
(21:07 +0100)
charcode.lisp
patch
|
blob
|
blame
|
history
diff --git
a/charcode.lisp
b/charcode.lisp
index
dfe5a19
..
ac1c74d
100644
(file)
--- a/
charcode.lisp
+++ b/
charcode.lisp
@@
-4,13
+4,19
@@
(defpackage :charcode
(:use :cl #+sbcl :sb-gray #-sbcl :gray)
(:export "MAKE-ENCODER" "MAKE-DECODER" "ENCODE-STRING" "DECODE-STRING" "SYSTEM-CHARSET"
(defpackage :charcode
(:use :cl #+sbcl :sb-gray #-sbcl :gray)
(:export "MAKE-ENCODER" "MAKE-DECODER" "ENCODE-STRING" "DECODE-STRING" "SYSTEM-CHARSET"
- "CODING-ERROR"
+ "
NO-CODEC-ERROR" "
CODING-ERROR"
"MAKE-CODEC-CHARACTER-STREAM"
"ASCII" "LATIN-1" "LATIN1" "UTF-8" "UTF8"))
(in-package :charcode)
;;; General stuff
"MAKE-CODEC-CHARACTER-STREAM"
"ASCII" "LATIN-1" "LATIN1" "UTF-8" "UTF8"))
(in-package :charcode)
;;; General stuff
+(define-condition no-codec-error (error)
+ ((codec-name :initarg :codec-name))
+ (:report (lambda (c s)
+ (with-slots (codec-name) c
+ (format s "Could find no codec named ~A." codec-name)))))
+
(define-condition coding-error (error)
((input :initarg :input)
(position :initarg :position)
(define-condition coding-error (error)
((input :initarg :input)
(position :initarg :position)
@@
-46,10
+52,12
@@
synonyms)))
(defun make-encoder (name)
synonyms)))
(defun make-encoder (name)
- (the encoder-fun (values (funcall (get name 'make-encoder)))))
+ (the encoder-fun (values (funcall (or (get name 'make-encoder)
+ (error 'no-codec-error :codec-name name))))))
(defun make-decoder (name)
(defun make-decoder (name)
- (the decoder-fun (values (funcall (get name 'make-decoder)))))
+ (the decoder-fun (values (funcall (or (get name 'make-decoder)
+ (error 'no-codec-error :codec-name name))))))
(defun system-charset ()
;; XXX: Replace me with something perhaps more sensible.
(defun system-charset ()
;; XXX: Replace me with something perhaps more sensible.