From 37be15261c35d732e6a254b75b77654ad0ad9d97 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Tue, 10 Sep 2019 21:44:45 +0200 Subject: Transforms some "assert" into error throws. --- src/map/query/map_update.erl | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/map') diff --git a/src/map/query/map_update.erl b/src/map/query/map_update.erl index ffdb37b..fbe9203 100644 --- a/src/map/query/map_update.erl +++ b/src/map/query/map_update.erl @@ -46,9 +46,21 @@ parse_input (Query) -> EncodedMapContent = maps:get(<<"t">>, JSONReqMap), %% TODO [LOW]: those checks should be done while queries are locked. - true = (MapWidth > 0), - true = (MapHeight > 0), - true = (length(EncodedMapContent) == (MapWidth * MapHeight)), + if + (MapWidth =< 0) -> error({map, width, MapWidth}); + (MapHeight =< 0) -> error({map, height, MapHeight}); + (length(EncodedMapContent) =/= (MapWidth * MapHeight)) -> + error + ( + { + map, + content_size, + (MapWidth * MapHeight), + length(EncodedMapContent) + } + ); + true -> ok + end, MapContent = lists:map(fun shr_tile_instance:decode/1, EncodedMapContent), -- cgit v1.2.3-70-g09d2