Mercurial > octave
changeset 22543:b9f5ac691e03
colormap.m: Emit clearer error when map name does not exist (bug #49202).
* colormap.m: Use try/catch block to 'feval (map)'. If map does not exist then
issue a clear error mesage in catch block. Add %!error test to validate new
behavior.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 27 Sep 2016 16:24:24 -0700 |
parents | e0a1e8803d8c |
children | 6763f91685da dadcd4f21889 |
files | scripts/image/colormap.m |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/image/colormap.m Tue Sep 27 12:38:57 2016 -0700 +++ b/scripts/image/colormap.m Tue Sep 27 16:24:24 2016 -0700 @@ -72,7 +72,11 @@ if (strcmp (map, "default")) map = viridis (64); else - map = feval (map); + try + map = feval (map); + catch + error ("colormap: failed to set MAP <%s>", map); + end_try_catch endif endif @@ -142,5 +146,5 @@ %!error <MAP must be a real-valued N x 3> colormap ([1 0 1 0]) %!error <all MAP values must be in the range> colormap ([-1 0 0]) %!error <all MAP values must be in the range> colormap ([2 0 0]) -%!error colormap ("invalid", "name") +%!error <failed to set MAP .invalid_map_name.> colormap ("invalid_map_name")