Merge pull request #2332 from alixander/d2js-compile-err-format

d2js: JSONify compile err msg
This commit is contained in:
Alexander Wang 2025-02-04 09:06:28 -08:00 committed by GitHub
commit e7639dab30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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.