Print file line number in Ogre 2.1 json parser errors.

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
hedphelym
Gremlin
Posts: 189
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 23
Contact:

Print file line number in Ogre 2.1 json parser errors.

Post by hedphelym »

Hi,
it would be very nice if the json parser could also log\print the line that has error,
some of our json files are over 8000 lines long (and growing), and finding 1 error in there is not too easy to track down always.
It would be nice to have this in Ogre by default (so that we do not need local changes to it just for this).
Would obviously also help others who use Ogre.

Code: Select all

        if( d.HasParseError() )
        {
            OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS,
                         "HlmsJson::loadMaterials",
                         "Invalid JSON string in file " + filename );
        } 
Put in this there to get the line number:

Code: Select all

d.GetErrorOffset() 
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: Print file line number in Ogre 2.1 json parser errors.

Post by al2950 »

+1
QuestOfDreams
Gnoblar
Posts: 6
Joined: Fri Nov 11, 2016 5:56 pm
Location: Austria
x 1

Re: Print file line number in Ogre 2.1 json parser errors.

Post by QuestOfDreams »

Sounds reasonable. +1
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 169

Re: Print file line number in Ogre 2.1 json parser errors.

Post by xrgo »

I don't use json but sounds very helpful +1
Post Reply