@@ -1458,7 +1458,15 @@ local function _processFileOrString(params, isFile)
14581458 local tok = tokenStack [# tokenStack ]
14591459
14601460 if isToken (tok , " pp_keyword" ) then
1461- if tok .value == " insert" then
1461+ if tok .value == " file" then
1462+ table.insert (tokens , {type = " string" , value = tok .file , representation = F (" %q" ,tok .file )})
1463+ tokenStack [# tokenStack ] = nil
1464+
1465+ elseif tok .value == " line" then
1466+ table.insert (tokens , {type = " number" , value = tok .line , representation = F (" %d" ,tok .line )})
1467+ tokenStack [# tokenStack ] = nil
1468+
1469+ elseif tok .value == " insert" then
14621470 local tokNext , iNext = getNextUsableToken (tokenStack , # tokenStack - 1 , nil , - 1 )
14631471 if not (tokNext and isToken (tokNext , " string" )) then
14641472 errorAtToken (
@@ -1988,8 +1996,7 @@ local function processFileOrString(params, isFile)
19881996 local returnValues = nil
19891997 local errorToReturn = nil
19901998
1991- isDebug = params .debug
1992- pushErrorHandler (function (err , levelFromOurError )
1999+ local function errHand (err , levelFromOurError )
19932000 if err == ERROR_REDIRECTION then return end
19942001
19952002 errorToReturn = err
@@ -2001,9 +2008,12 @@ local function processFileOrString(params, isFile)
20012008 if params .onError then params .onError (errorToReturn ) end
20022009
20032010 if levelFromOurError then _error (ERROR_REDIRECTION ) end
2004- end )
2011+ end
20052012
2006- xpcall (
2013+ isDebug = params .debug
2014+ pushErrorHandler (errHand )
2015+
2016+ local xpcallOk , xpcallErr = xpcall (
20072017 function ()
20082018 returnValues = pack (_processFileOrString (params , isFile ))
20092019 end ,
@@ -2020,8 +2030,16 @@ local function processFileOrString(params, isFile)
20202030 metaPathForErrorMessages = " "
20212031 outputFromMeta = nil
20222032
2033+ -- Unhandled error.
2034+ if not (returnValues or errorToReturn ) then
2035+ pcall (errHand , (not xpcallOk and xpcallErr or " Unknown processing error." ))
2036+ end
2037+
2038+ -- Handled error.
20232039 if errorToReturn then
20242040 return nil , errorToReturn
2041+
2042+ -- Success.
20252043 else
20262044 return unpack (returnValues , 1 , returnValues .n )
20272045 end
0 commit comments