d2js: JSONify compile err msg

This commit is contained in:
Alexander Wang 2025-02-04 10:01:08 -07:00
parent 6eb792329d
commit 7fd7fea0e7
No known key found for this signature in database
GPG key ID: BE3937D0D52D8927
2 changed files with 2 additions and 1 deletions

View file

@ -213,7 +213,8 @@ func Compile(args []js.Value) (interface{}, error) {
}, renderOpts)
if err != nil {
if pe, ok := err.(*d2parser.ParseError); ok {
return nil, &WASMError{Message: pe.Error(), Code: 400}
errs, _ := json.Marshal(pe.Errors)
return nil, &WASMError{Message: string(errs), Code: 400}
}
return nil, &WASMError{Message: err.Error(), Code: 500}
}

BIN
d2js/js/d2.wasm Executable file

Binary file not shown.