3030# ' <https://doi.org/10.2909/960998c1-1870-4e82-8051-6485205ebbac>
3131
3232CLC_process <- function (
33- env_file = " .env" , min_land_percent = 15 , plot_CLC = TRUE ) {
33+ env_file = " .env" , min_land_percent = 15 , plot_CLC = TRUE ) {
3434 # # ..................................................................... ###
3535
3636 .StartTime <- lubridate :: now(tzone = " CET" )
@@ -46,21 +46,19 @@ CLC_process <- function(
4646 EU_Bound <- Value <- Country <- Country2 <- NULL
4747
4848 if (is.null(env_file )) {
49- stop (" env_file can not be empty" , call. = FALSE )
49+ IASDT.R :: stop_ctx (" env_file can not be empty" , env_file = env_file )
5050 }
5151
5252 if (! is.numeric(min_land_percent ) ||
5353 ! dplyr :: between(min_land_percent , 0 , 100 )) {
54- stop (
54+ IASDT.R :: stop_ctx (
5555 " `min_land_percent` must be a numeric value between 0 and 100." ,
56- call. = FALSE )
56+ min_land_percent = min_land_percent )
5757 }
5858
5959 if (! file.exists(env_file )) {
60- stop(
61- " Path to environment variables (`env_file`): " , env_file ,
62- " was not found" ,
63- call. = FALSE )
60+ IASDT.R :: stop_ctx(
61+ " Path to environment variables was not found" , env_file = env_file )
6462 }
6563
6664 # # ..................................................................... ###
@@ -106,7 +104,7 @@ CLC_process <- function(
106104 .x = requiredPaths ,
107105 .f = function (path ) {
108106 if (! file.exists(path )) {
109- stop (" Required path does not exist: " , path , call. = FALSE )
107+ IASDT.R :: stop_ctx (" Required path does not exist: " , path = path )
110108 }
111109 }
112110 )
@@ -627,15 +625,19 @@ CLC_get_percentage <- function(
627625
628626 if (is.null(CLC_type ) || is.null(CLC_crossWalk ) || is.null(CLC_fracs_r ) ||
629627 is.null(path_tif ) || is.null(path_RData )) {
630- stop(" None of the input parameters can be empty" , call. = FALSE )
628+ IASDT.R :: stop_ctx(
629+ " None of the input parameters can be empty" ,
630+ CLC_type = CLC_type , CLC_crossWalk = CLC_crossWalk ,
631+ CLC_fracs_r = CLC_fracs_r , path_tif = path_tif , path_RData = path_RData )
631632 }
632633
633634 if (! (
634635 CLC_type %in% c(" SynHab" , " CLC_L1" , " CLC_L2" , " CLC_L3" , " EUNIS_2019" ))) {
635- stop(
636- " CLC_type has to be one of SynHab, CLC_L1, CLC_L2, " ,
637- " CLC_L3, and EUNIS_2019" ,
638- call. = FALSE )
636+ IASDT.R :: stop_ctx(
637+ paste0(
638+ " CLC_type has to be one of SynHab, CLC_L1, CLC_L2, " ,
639+ " CLC_L3, and EUNIS_2019" ),
640+ CLC_type = CLC_type )
639641 }
640642 # # ..................................................................... ###
641643
@@ -721,15 +723,21 @@ CLC_get_majority <- function(
721723 if (is.null(CLC_type ) || is.null(CLC_majority ) || is.null(path_tif ) ||
722724 is.null(path_tif_crop ) || is.null(path_RData ) || is.null(Grid_10_Land ) ||
723725 is.null(Grid_10_Land_Crop )) {
724- stop(" None of the input parameters can be empty" , call. = FALSE )
726+ IASDT.R :: stop_ctx(
727+ " None of the input parameters can be empty" ,
728+ CLC_type = CLC_type , CLC_majority = CLC_majority ,
729+ path_tif = path_tif , path_tif_crop = path_tif_crop ,
730+ path_RData = path_RData , Grid_10_Land = Grid_10_Land ,
731+ Grid_10_Land_Crop = Grid_10_Land_Crop )
725732 }
726733
727734 if (! (
728735 CLC_type %in% c(" SynHab" , " CLC_L1" , " CLC_L2" , " CLC_L3" , " EUNIS_2019" ))) {
729- stop(
730- " CLC_type has to be one of SynHab, CLC_L1, CLC_L2, " ,
731- " CLC_L3, and EUNIS_2019" ,
732- call. = FALSE )
736+ IASDT.R :: stop_ctx(
737+ paste0(
738+ " CLC_type has to be one of SynHab, CLC_L1, CLC_L2, " ,
739+ " CLC_L3, and EUNIS_2019" ),
740+ CLC_type = CLC_type )
733741 }
734742
735743 # # ..................................................................... ###
0 commit comments