@@ -6,7 +6,6 @@ package flowpathmapper
66
77import (
88 "github.com/dfeyer/flow-debugproxy/config"
9- "github.com/dfeyer/flow-debugproxy/errorhandler"
109 "github.com/dfeyer/flow-debugproxy/logger"
1110 "github.com/dfeyer/flow-debugproxy/pathmapperfactory"
1211 "github.com/dfeyer/flow-debugproxy/pathmapping"
@@ -16,9 +15,9 @@ import (
1615 "io/ioutil"
1716 "os"
1817 "regexp"
18+ "runtime"
1919 "strconv"
2020 "strings"
21- "runtime"
2221)
2322
2423const (
@@ -63,32 +62,34 @@ func (p *PathMapper) Initialize(c *config.Config, l *logger.Logger, m *pathmappi
6362}
6463
6564// ApplyMappingToTextProtocol change file path in xDebug text protocol
66- func (p * PathMapper ) ApplyMappingToTextProtocol (message []byte ) []byte {
67- return p .doTextPathMapping (message )
65+ func (p * PathMapper ) ApplyMappingToTextProtocol (message []byte ) ( []byte , error ) {
66+ return p .doTextPathMapping (message ), nil
6867}
6968
7069// ApplyMappingToXML change file path in xDebug XML protocol
71- func (p * PathMapper ) ApplyMappingToXML (message []byte ) []byte {
70+ func (p * PathMapper ) ApplyMappingToXML (message []byte ) ( []byte , error ) {
7271 message = p .doXMLPathMapping (message )
7372
7473 // update xml length count
7574 s := strings .Split (string (message ), "\x00 " )
7675 i , err := strconv .Atoi (s [0 ])
77- errorhandler .PanicHandling (err , p .logger )
76+ if err != nil {
77+ return nil , err
78+ }
7879 l := len (s [1 ])
7980 if i != l {
8081 message = bytes .Replace (message , []byte (strconv .Itoa (i )), []byte (strconv .Itoa (l )), 1 )
8182 }
8283
83- return message
84+ return message , nil
8485}
8586
8687func (p * PathMapper ) doTextPathMapping (message []byte ) []byte {
8788 var processedMapping = map [string ]string {}
8889 for _ , match := range regexpPhpFile .FindAllStringSubmatch (string (message ), - 1 ) {
8990 originalPath := match [1 ]
9091 if runtime .GOOS == "windows" {
91- originalPath = strings .Replace (originalPath ,"//" ,"" , 1 )
92+ originalPath = strings .Replace (originalPath , "//" , "" , 1 )
9293 }
9394 path := p .mapPath (originalPath )
9495 p .logger .Debug ("doTextPathMapping %s >>> %s" , path , originalPath )
@@ -183,7 +184,10 @@ func (p *PathMapper) readOriginalPathFromCache(path, basePath string) string {
183184 }
184185 p .logger .Debug ("readOriginalPathFromCache %s" , localPath )
185186 dat , err := ioutil .ReadFile (localPath )
186- errorhandler .PanicHandling (err , p .logger )
187+ if err != nil {
188+ p .logger .Warn (err .Error ())
189+ return localPath
190+ }
187191 match := regexpPathAndFilename .FindStringSubmatch (string (dat ))
188192 if len (match ) == 2 {
189193 originalPath := match [1 ]
0 commit comments