summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-09-10 21:44:45 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-09-10 21:44:45 +0200
commit37be15261c35d732e6a254b75b77654ad0ad9d97 (patch)
tree34102799ff0f16982d3b7b4c87f5f1b6a4bdd923 /src/map/query/map_update.erl
parentcfdd37c261bfb814740aa8cec30177f9c5f85d36 (diff)
Transforms some "assert" into error throws.
Diffstat (limited to 'src/map/query/map_update.erl')
-rw-r--r--src/map/query/map_update.erl18
1 files changed, 15 insertions, 3 deletions
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),