Skip to content

Commit

Permalink
Handle missing nodes more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
tmdvs committed Oct 17, 2024
1 parent e4e9738 commit 2cc98b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/converter/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from sketchformat.layer_common import *
from sketchformat.layer_shape import *
from sketchformat.style import *
from .errors import *
from typing import TypedDict

from . import positioning, style, prototype, utils
Expand Down
6 changes: 5 additions & 1 deletion src/converter/context.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from urllib.error import HTTPError
from . import component, page, font
from .errors import Fig2SketchWarning
from sketchformat.document import Swatch
from typing import Sequence, Tuple, Optional, Dict, IO, List

Expand Down Expand Up @@ -59,7 +60,10 @@ def add_symbol(self, sketch_symbol):
self._position_symbol(sketch_symbol)

def fig_node(self, fid: Sequence[int]) -> dict:
return self._node_by_id[fid]
if fid in self._node_by_id:
return self._node_by_id[fid]
else:
raise Fig2SketchWarning("NOD001")

def record_font(self, fig_font_name):
font_descriptor = (fig_font_name["family"], fig_font_name["style"])
Expand Down
2 changes: 1 addition & 1 deletion src/converter/prototype.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .context import context
from .errors import Fig2SketchWarning
from .errors import *
from converter import utils
from sketchformat.prototype import *
from typing import TypedDict, Tuple, Optional
Expand Down

0 comments on commit 2cc98b9

Please sign in to comment.