-
Notifications
You must be signed in to change notification settings - Fork 0
Return Code Problems
Return code
Problems caused by lack of proper Return code support in internal functions
[--> 'List of Sql-Commands'] (Home#commands)
[<-- 'Index Page for RasterLite2 - Commands'] (RasterLite2-Index#commands)
[<-- 'Cutline / RasterDefaults Index'] (Cutline-Index#return_codes)
A major problem while
- searching for errors
- understanding the flow of the Library
is the lack of a meaningful return code when errors occur
- 1 : success
- 0 : failed
- -1 : general parameter error, otherwise not known
is, as a general rule, all that is returned.
Due to the complexity of tasks being completed
- through checks are being done
- but the true cause is not being stored or being reported
The time spent in searching for such errors
- is very high
- so often I have build in errors codes
- and i_rc variable with a default value of 0
- each error determined (in the order found)
- receives a minus value, starting with
-1
,-2
etc.- before the horrid goto error was called
- or grouped according to some function typical logic
- in the sample below, the groups are data-types
-
*_BIT
,INT*
,UINT*
etc.
-
- in combination with
-
RGB
,GRAYSCALE
,PALETTE
,MULTIBAND
etc.
-
- in the sample below, the groups are data-types
- receives a minus value, starting with
- so often I have build in errors codes
One sample in rl2tiff.c
-
check_tiff_origin_pixel_conversion
- this function determined an error
-
RL2_LoadRaster
had failed with-1
- 2-3 hours later, I found that the error was determined here
- the cause of the error was elsewhere
- 2-3 hours later, I found that the error was determined here
- there are about 25 different error possibilities
- to resolve the problem, you must know which
- In this case it was a 1_BIT, MONOCHROME, bitsPerSample error
- with a value of 16604
-
bitsPerSample: default: 1 ; maximum: 8
- so where does 16604 come from
-
bitsPerSample: default: 1 ; maximum: 8
- with a value of 16604
So after about 5-6 hours
- the point where the error was determined is known
The cause of the problem was elsewhere
-
init_tiff_origin
- the LIBTIFF function
TIFFGetField
for retrievingTIFFTAG_BITSPERSAMPLE
- was being used without checking the return code
- in this case the GeoTiff had no field with
TIFFTAG_BITSPERSAMPLE
- in this case
1
should be set
- in this case
- due to the missing check, garbage was returned (16604)
- this was the only case, where no checking was done
- in this case the GeoTiff had no field with
- was being used without checking the return code
- the LIBTIFF function
TIFFGetFieldDefaulted
- will return, when the GeoTiff has no
TIFFTAG
being queried- the predefined default value
-
not all
TIFFTAG
are supported-
TIFFTAG_BITSPERSAMPLE
is, however, supported
-
-
not all
- the predefined default value
- will return, when the GeoTiff has no
- the LIBTIFF function
Resolvement:
- in cases where
TIFFGetFieldDefaulted
- will return (without a need to check the return code) a default value
-
TIFFGetField
was replaced withTIFFGetFieldDefaulted
-
- will return (without a need to check the return code) a default value
- otherwise
-
TIFFGetField
with the checking of the return code is used
-
It was after this full work day
- that I started to retained these return codes
- up to then I had removed them
- adding a switch/case
- with a short description on what the code means
I would advice, that where needed
- that this system be continued
[<-- 'Cutline / RasterDefaults Index'] (Cutline-Index#return_codes)
2015-11-12: Mark Johnson, Berlin Germany