obfuscate Playwright from errors

This commit is contained in:
Bernard Xie 2022-11-17 16:56:38 -08:00
parent 6a00cfb005
commit 3f517fd1c3
No known key found for this signature in database
GPG key ID: 3C3E0036CE0F892C

View file

@ -73,7 +73,7 @@ func InitPlaywright() (Playwright, error) {
cmd := exec.Command(driver.DriverBinaryLocation, "--version") cmd := exec.Command(driver.DriverBinaryLocation, "--version")
output, err := cmd.Output() output, err := cmd.Output()
if err != nil { if err != nil {
return Playwright{}, fmt.Errorf("could not install Playwright driver: %v\nplease report this issue here: https://github.com/terrastruct/d2/issues/new", err.Error()) return Playwright{}, fmt.Errorf("error installing png exporter: %v\nplease report this issue here: https://github.com/terrastruct/d2/issues/new", err.Error())
} }
if !bytes.Contains(output, []byte(driver.Version)) { if !bytes.Contains(output, []byte(driver.Version)) {
err = playwright.Install() err = playwright.Install()
@ -82,7 +82,7 @@ func InitPlaywright() (Playwright, error) {
} }
} }
} else { } else {
return Playwright{}, fmt.Errorf("could not find Playwright binary: %v\nplease report this issue here: https://github.com/terrastruct/d2/issues/new", err.Error()) return Playwright{}, fmt.Errorf("could not install png exporter: %v\nplease report this issue here: https://github.com/terrastruct/d2/issues/new", err.Error())
} }
pw, err := playwright.Run() pw, err := playwright.Run()
@ -97,7 +97,7 @@ var genPNGScript string
func ExportPNG(ms *xmain.State, page playwright.Page, svg []byte) (outputImage []byte, err error) { func ExportPNG(ms *xmain.State, page playwright.Page, svg []byte) (outputImage []byte, err error) {
if page == nil { if page == nil {
return nil, fmt.Errorf("Playwright was not initialized properly for PNG export") return nil, fmt.Errorf("png exporter was not initialized properly\nplease report this issue here: https://github.com/terrastruct/d2/issues/new")
} }
encodedSVG := base64.StdEncoding.EncodeToString(svg) encodedSVG := base64.StdEncoding.EncodeToString(svg)