You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The NewTile function simply fills in the fields but it should do input validation, for example the tile {Z:0, X: 99, Y:99} does not exist.
I can see two solutions, changing the function signature to func NewTile(z, x, y uint) (*Tile, error) or returning nil from the current function if the tile does not exist.
New Signature
pros:
more explicit error state
error state is a compile error
tile := slippy.NewTile(...); tile.Dereference is caught by the compiler
the returned error can be created in geom
cons:
breaking change
Return nil
pros:
non-breaking
error state would give a runtime error (better than going un-noticed)
tile := slippy.NewTile(...); tile.Dereference is a nil pointer dereference at runtime
cons:
error state is would give a runtime error (not as helpful as a compiler error)
The text was updated successfully, but these errors were encountered:
geom/slippy/tile.go
Lines 15 to 21 in 2760310
The
NewTile
function simply fills in the fields but it should do input validation, for example the tile{Z:0, X: 99, Y:99}
does not exist.I can see two solutions, changing the function signature to
func NewTile(z, x, y uint) (*Tile, error)
or returningnil
from the current function if the tile does not exist.New Signature
pros:
tile := slippy.NewTile(...); tile.Dereference
is caught by the compilercons:
Return
nil
pros:
tile := slippy.NewTile(...); tile.Dereference
is a nil pointer dereference at runtimecons:
The text was updated successfully, but these errors were encountered: