nansat icon indicating copy to clipboard operation
nansat copied to clipboard

Standardize return values on failure/success

Open aleksandervines opened this issue 9 years ago • 5 comments

For the most part, it seems that methods return 1 on failure and 0 on success.

Node.node() returns False on fail (if node is not found). Which is completely opposite as False corresponds to 0.

Some methods just return (with no value), e.g. Nansat.reproject with dstDomain=None

I believe this should be standardize throughout the whole of nansat.

Any seconds for that, and I can assign myself to this.

aleksandervines avatar Oct 16 '15 13:10 aleksandervines

agree!

On 16 October 2015 at 15:30, Aleksander Vines [email protected] wrote:

For the most part, it seems that methods return 1 on failure and 0 on success.

Node.node() returns False on fail (if node is not found). Which is completely opposite as False corresponds to 0.

Some methods just return (with no value), e.g. Nansat.reproject with dstDomain=None

I believe this should be standardize throughout the whole of nansat.

Any seconds for that, and I can assign myself to this.

— Reply to this email directly or view it on GitHub https://github.com/nansencenter/nansat/issues/146.

mortenwh avatar Oct 16 '15 13:10 mortenwh

Job schedulers (on big computers) usually handle STDERR errors well (proper message handling is not so obvious when everything just goes to the screen); just saying...

see also http://stackoverflow.com/questions/5574702/how-to-print-to-stderr-in-python from future import print_function def warning(*objs): print("WARNING: ", *objs, file=sys.stderr)

rickedanielson avatar Oct 16 '15 13:10 rickedanielson

This issue is relevant to #54 but is more general. Closing #54 ...

akorosov avatar Oct 19 '15 13:10 akorosov

I agree with @aleksandervines Note of @rickedanielson is more relevant for how to raise errors and output warnring/error messages. This is currently done using children of Exception and self.logger.error() or self.logger.warning()

akorosov avatar Oct 19 '15 13:10 akorosov

For some methods it may conflict with #164. Fix is required only for the methods which will not return Nansat

akorosov avatar Apr 22 '16 18:04 akorosov