[fpc-devel] fpjson/jsonparser: EJSONScanner vs EScannerError
    Michael Van Canneyt 
    michael at freepascal.org
       
    Sun May 29 23:57:30 CEST 2011
    
    
  
On Sun, 29 May 2011, Luiz Americo Pereira Camara wrote:
> I found that to handle error while parsing json through TJSONParser is 
> necessary to consider two types of exceptions:
>
> EJSONScanner from jsonparser
> EScannerError from jsonscanner
>
> This has the drawback of need to duplicate code like:
>
>   on E: EJSONScanner do
>    begin
>      ShowMessageFmt('Error parsing "%s" : %s', [FileName, E.Message]);
>    end;
>    on E: EScannerError do
>    begin
>      ShowMessageFmt('Error parsing "%s" : %s', [FileName, E.Message]);
>    end;
>
> Also requires to add jsonscanner to uses clause
>
> Is it supposed to be this way?
> Is there any benefit?
Well, there are 2 different kinds of errors: scanner errors, and parser errors.
They should have 2 different classes.
> Should a bug report be made?
You can submit a request so they are merged (or one made a descendent of the other).
Mochael.
    
    
More information about the fpc-devel
mailing list