I'm making a little cli app for interpolating templates of my config files. It take paths to scan as argument and if any of them is directory i create a std.Io.Dir.Walker and iterating over them, if it's not cli just fills template and write it to a new file.
Problem is: in case of SOME errors i want to provide useful information for example if path which is provided as dest doesn't exist or app doesn't have access to it, i want to log the error and a path which caused error. If i use catch |e| and switch on error manually it creates A LOT of boilerplate code, because i want to have errors for provided config_dir, dest_paths and templating. Also because app can accept dest_path as dir OR as a file i have repeated logic like this:

