Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] PXP
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Gerd Stolpmann <info@g...>
Subject: Re: [Caml-list] PXP

On 2002.06.04 18:19 Gaurav Chanda wrote:
> Hello
> 
> I am using PXP to parse and validate an XML document. The follwing code 	
> 
> 
> <?xml version="1.0"?>
> <methodCall>
>   <methodName>examples.getStateName</methodName>
>   <params>
>     <param>
>       <value><i4>41</i4></value>
>       </param>
>     </params>
>   </methodCall>
> 
> gave this error at runtime: 
>   Fatal error: exception Pxp_types.At("In entity [toplevel] = ANONYMOUS, at line 2, position 12:", _)
> 
> Could anybody help me solve this problem ?

In addition to Stefano's answer: Unfortunately, you do not get the full error message. 
This is an annoying problem of the runtime environment. Try the following code in the 
toploop:

# raise(At("x",WF_error "y"));;
Exception: Pxp_types.At ("x", Pxp_types.WF_error "y").
# try raise(At("x",WF_error "y")) with any -> Failure(Printexc.to_string any);;
- : exn = Failure "Pxp_types.At(_)"
 
If you compile raise(At("x",WF_error "y")), and start the program, you get a third 
variant:

Fatal error: exception Pxp_types.At("x", _)

There are three different built-in routines to print uncaught exceptions, and all three
have different capabilitites, and only one can print nested exceptions.

The workaround for PXP is to use the special exception printer Pxp_types.string_of_exn
like

try
  <your code raising the exception>
with
  error ->
    failwith(Pxp_types.string_of_exn error)

and you get always an exception that can be printed, regardless which printer happens
to catch the exception.

Gerd
-- 
----------------------------------------------------------------------------
Gerd Stolpmann      Telefon: +49 6151 997705 (privat)
Viktoriastr. 45             
64293 Darmstadt     EMail:   gerd@gerd-stolpmann.de
Germany                     
----------------------------------------------------------------------------
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners