Skip to content

Commit

Permalink
If no map in wtg then display the canvas
Browse files Browse the repository at this point in the history
optional labels
  • Loading branch information
owulveryck committed Jun 12, 2023
2 parents 885baaa + f1943ad commit dd11d60
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/webassembly/wasm/main.go
Expand Up @@ -124,7 +124,7 @@ func wtg2SVG(s string, width int, height int, withAnnotations bool) (string, err

buf := bytes.NewBufferString(s)
err := p.Parse(buf)
if err != nil {
if err != nil && err != wtg.ErrEmptyMap {
return "", err
}
if len(p.InvalidEntries) != 0 {
Expand Down
2 changes: 1 addition & 1 deletion examples/wtg2svg/main.go
Expand Up @@ -40,7 +40,7 @@ func main() {
p := wtg.NewParser()

err = p.Parse(os.Stdin)
if err != nil {
if err != nil && err != wtg.ErrEmptyMap {
log.Fatal(err)
}
if len(p.InvalidEntries) != 0 {
Expand Down
5 changes: 4 additions & 1 deletion parser/wtg/parse.go
@@ -1,6 +1,7 @@
package wtg

import (
"errors"
"fmt"
"image"
"io"
Expand All @@ -11,6 +12,8 @@ import (
svgmap "github.com/owulveryck/wardleyToGo/encoding/svg"
)

var ErrEmptyMap = errors.New("no map")

type Parser struct {
visibilityOnly bool
WMap *wardleyToGo.Map
Expand Down Expand Up @@ -60,7 +63,7 @@ func (p *Parser) parse(s string) error {
return fmt.Errorf("error in parsing: %w", err)
}
if len(inv.NodeInventory) == 0 {
return fmt.Errorf("no map")
return ErrEmptyMap
}
m, err := consolidateMap(inv.NodeInventory, inv.EdgeInventory)
if err != nil {
Expand Down

0 comments on commit dd11d60

Please sign in to comment.