From: Jan Vroonhof <vroonhof@math.ethz.ch>
Subject: Re: pgnus-0.31: invoke external MIME stuff
Date: 25 Sep 1998 13:15:56 +0200 [thread overview]
Message-ID: <by90j8wihf.fsf@bolzano.math.ethz.ch> (raw)
In-Reply-To: Lars Magne Ingebrigtsen's message of "Thu, 24 Sep 1998 20:53:38 GMT"
Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
> > > No -- base64 throws errors is the region in question isn't a valid
> > > base64 file, if I recall correctly.
> >
> > Shouldn't you be catching JUST that error?
>
> How does one catch an error thrown by `error' and no other errors?
One fixes the library (in this case base-64.el) to signal a more
specialised error, like this
(condition-case ()
(base64-decode-region (point-min) (point-max))
(mime-conversion-error nil))
diff -u /u/scratch/vroonhof/xemacs/gnus/pgnus-0.32/lisp/base64.el~ /u/scratch/vroonhof/xemacs/gnus/pgnus-0.32/lisp/base64.el
--- /u/scratch/vroonhof/xemacs/gnus/pgnus-0.32/lisp/base64.el~ Fri Sep 25 13:14:06 1998
+++ /u/scratch/vroonhof/xemacs/gnus/pgnus-0.32/lisp/base64.el Fri Sep 25 13:14:06 1998
@@ -29,6 +29,16 @@
(if (not (fboundp 'char-int))
(fset 'char-int 'identity))
+(define-error 'mime-conversion-error "Error in coverting encoded data.")
+; As data we return (list <number of> <units>) where units is 'bits
+(define-error 'mime-short-coding-string
+ "The encoded string is short"
+ 'mime-conversion-error)
+(define-error 'mime-external-program-error
+ "External conversion program error"
+ 'mime-conversion-error)
+
+
(defvar base64-alphabet
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
@@ -134,7 +144,7 @@
base64-decoder-program
base64-decoder-switches)))
(if (not (eq status t))
- (error "%s" (cdr status))))
+ (signal-error 'mime-external-program-error (cdr status))))
(goto-char start)
(skip-chars-forward non-data-chars end)
(while (not done)
@@ -159,13 +169,13 @@
(cond
((= (point) end)
(if (not (zerop counter))
- (error "at least %d bits missing at end of base64 encoding"
- (* (- 4 counter) 6)))
+ (signal-error 'mime-short-coding-string
+ (list (* (- 4 counter) 6) 'bits)))
(setq done t))
((= (char-after (point)) ?=)
(setq done t)
(cond ((= counter 1)
- (error "at least 2 bits missing at end of base64 encoding"))
+ (signal-error 'mime-short-coding-string '(2 bits))
((= counter 2)
(base64-insert-char (lsh bits -10) 1 nil work-buffer))
((= counter 3)
@@ -201,7 +211,7 @@
base64-encoder-program
base64-encoder-switches)))
(if (not (eq status t))
- (error "%s" (cdr status))))
+ (signal-error 'mime-external-program-error (list (cdr status)))))
(setq inputpos start)
(while (< inputpos end)
(setq bits (+ bits (char-int (char-after inputpos))))
next prev parent reply other threads:[~1998-09-25 11:15 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-09-23 15:39 Kai Grossjohann
1998-09-23 15:47 ` Lee Willis
1998-09-23 16:44 ` Kai Grossjohann
1998-09-23 16:10 ` Shenghuo ZHU
1998-09-23 16:43 ` Kai Grossjohann
1998-09-23 18:55 ` Matt Armstrong
1998-09-23 18:56 ` Jan Vroonhof
1998-09-23 22:21 ` Lars Magne Ingebrigtsen
1998-09-24 10:03 ` Jan Vroonhof
1998-09-24 17:13 ` Lars Magne Ingebrigtsen
1998-09-25 11:15 ` Jan Vroonhof [this message]
1998-09-25 13:58 ` Simon Josefsson
1998-09-25 14:17 ` Alan Shutko
1998-09-25 15:59 ` Hrvoje Niksic
1998-09-26 18:11 ` Jan Vroonhof
1998-09-29 10:43 ` Lars Magne Ingebrigtsen
1998-09-29 12:57 ` Jan Vroonhof
1998-10-01 2:39 ` Lars Magne Ingebrigtsen
1998-10-01 9:01 ` Jan Vroonhof
1998-10-01 9:12 ` Lars Magne Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=by90j8wihf.fsf@bolzano.math.ethz.ch \
--to=vroonhof@math.ethz.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).