+
+validate_args :: Args -> IO ()
+validate_args Args{..} = do
+ when (scale <= 0) $ do
+ hPutStrLn stderr "ERROR: scale must be greater than zero."
+ exitWith (ExitFailure exit_arg_not_positive)
+
+ when (width <= 0) $ do
+ hPutStrLn stderr "ERROR: width must be greater than zero."
+ exitWith (ExitFailure exit_arg_not_positive)
+
+ when (height <= 0) $ do
+ hPutStrLn stderr "ERROR: height must be greater than zero."
+ exitWith (ExitFailure exit_arg_not_positive)
+
+ when (depth <= 0) $ do
+ hPutStrLn stderr "ERROR: depth must be greater than zero."
+ exitWith (ExitFailure exit_arg_not_positive)
+
+ case slice of
+ Just s ->
+ when (s < 0 || s > depth) $ do
+ hPutStrLn stderr "ERROR: slice must be between zero and depth."
+ exitWith (ExitFailure exit_arg_out_of_bounds)
+ Nothing -> return ()