[plt-scheme] raise error

From: Rainer Gross (rainer_gross at gmx.net)
Date: Mon Jan 29 21:08:55 EST 2007

Thanx 4 the answer but I can't use the suggested function ...

Since I am interested in raising error messages for the end user I  
don't have any symbol to inform. Therefore the (error src-symbol  
format-string v ···) definition is not useful in my case. But yes I  
want to have the format string like behavior of this function or even  
better the java like "hello" + a + "world".

In PLT MzScheme Language Manual section 6.2 Errors it is the second  
form I am using:

It says:
(error msg-string v ···) creates a message string by concatenating  
msg-string with string versions of the vs (as produced by the current  
error value conversion handler; see section A space is  
inserted before each v.

The write + exn-message is only to demonstrate the result. The error  
may be attended in different ways.

I would like something like string-append but that is aware of type  
and inserts the extra blanks as offered by (error msg-string v ...)  
as indicated by the documentation.


On Jan 29, 2007, at 10:33 PM, Robby Findler wrote:

> Probably you wanted to write:
> (error 'my-function "this is the message: ~s ~s" (list 'a 'value)
> (vector 'another 'value))
> That is, pass a symbol as the first argument to error and you should
> get the behavior you intend.
> (Also, you probably want to use the error-print-handler, rather than
> write + exn-message).
> Robby
> On 1/29/07, Rainer Gross <rainer_gross at gmx.net> wrote:
>> Hello there!
>> I am using the (error str v ...) function to raise exceptions in
>> error cases. But I wonder about the result when i print the error
>> message.
>> The following is the result in the interaction window of DrScheme:
>>  > (with-handlers ([exn? (lambda (exn) (write (exn-message exn)))])
>>    (error "First part" "second part"))
>> "First part \"second part\""
>> I would have had expected:
>> "First part second part"
>> Why is it that the second and any subsequent strings are escaped? It
>> seams that all parameters following the initial String are inserted
>> into this string and not concatenated as described in the
>> documentation. Only non string values are really concatenated.
>> Is this a known problem, is there something I am doing wrong or I
>> misinterpret the documentation. Is there a better way to do this?
>> Mostly the error text is somthing like the following: (error "The "
>> limit-type "was exceeded by" anything) where the symbols resolve to
>> symbols, numbers or strings.
>> Any help would be appreciated.
>> Best Regards,
>> Rainer
>> _________________________________________________
>>   For list-related administrative tasks:
>>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.