diff --git a/matlab/draw_prior_density.m b/matlab/draw_prior_density.m
index 271b0124ed6f7045ebe4b7d493a99a6863f2417b..c8b77e67f420ea1eee7bcbb623740de44dceb949 100644
--- a/matlab/draw_prior_density.m
+++ b/matlab/draw_prior_density.m
@@ -14,7 +14,7 @@ function [x,f,abscissa,dens,binf,bsup] = draw_prior_density(indx,bayestopt_)
 %    bsup:         [double]     Scalar, last element of x
 
 
-% Copyright © 2004-2017 Dynare Team
+% Copyright © 2004-2023 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -49,17 +49,8 @@ switch pshape(indx)
     dens = density(abscissa,p6(indx),p7(indx),p3(indx),p4(indx));
   case 2% Generalized Gamma prior
     density = @(x,a,b,c) gampdf(x-c,a,b);
-    try
-        infbound = gaminv(truncprior,p6(indx),p7(indx))+p3(indx);
-        supbound = gaminv(1-truncprior,p6(indx),p7(indx))+p3(indx);
-    catch
-        % Workaround for ticket #161, see http://savannah.gnu.org/bugs/?52569
-        if isoctave
-            error(['Due to a computational limitation in Octave, the prior cannot be plotted. You must either use plot_priors=0 or choose other values for mean and/or variance of your prior on ' bayestopt_.name{indx} ', or use another shape'])
-        else
-            rethrow(lasterror)
-        end
-    end
+    infbound = gaminv(truncprior,p6(indx),p7(indx))+p3(indx);
+    supbound = gaminv(1-truncprior,p6(indx),p7(indx))+p3(indx);
     abscissa = linspace(infbound,supbound,steps);
     dens = density(abscissa,p6(indx),p7(indx),p3(indx));
   case 3% Gaussian prior
@@ -68,17 +59,8 @@ switch pshape(indx)
     abscissa = linspace(infbound,supbound,steps);
     dens = normpdf(abscissa,p6(indx),p7(indx));
   case 4% Inverse-gamma of type 1 prior
-    try
-        infbound = 1/sqrt(gaminv(1-10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx);
-        supbound = 1/sqrt(gaminv(10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx);
-    catch
-        % Workaround for ticket #161, see http://savannah.gnu.org/bugs/?52569
-        if isoctave
-            error(['Due to a computational limitation in Octave, the prior cannot be plotted. You must either use plot_priors=0 or choose other values for mean and/or variance of your prior on ' bayestopt_.name{indx} ', or use another shape'])
-        else
-            rethrow(lasterror)
-        end
-    end
+    infbound = 1/sqrt(gaminv(1-10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx);
+    supbound = 1/sqrt(gaminv(10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx);
     abscissa = linspace(infbound,supbound,steps);
     dens = exp(lpdfig1(abscissa-p3(indx),p6(indx),p7(indx)));
   case 5% Uniform prior
@@ -87,17 +69,8 @@ switch pshape(indx)
     abscissa = linspace(infbound,supbound,steps);
     dens = ones(1, steps) / (supbound-infbound);
   case 6% Inverse-gamma of type 2 prior
-    try
-        infbound = 1/(gaminv(1-10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx);
-        supbound = 1/(gaminv(10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx);
-    catch
-        % Workaround for ticket #161, see http://savannah.gnu.org/bugs/?52569
-        if isoctave
-            error(['Due to a computational limitation in Octave, the prior cannot be plotted. You must either use plot_priors=0 or choose other values for mean and/or variance of your prior on ' bayestopt_.name{indx} ', or use another shape'])
-        else
-            rethrow(lasterror)
-        end
-    end
+    infbound = 1/(gaminv(1-10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx);
+    supbound = 1/(gaminv(10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx);
     abscissa = linspace(infbound,supbound,steps);
     dens = exp(lpdfig2(abscissa-p3(indx),p6(indx),p7(indx)));
   case 8
diff --git a/matlab/prior_bounds.m b/matlab/prior_bounds.m
index cf75923511acea64f67c4199c64ff51f43646c37..8749f681824874ddfa9ad4b90f93169ee006ca55 100644
--- a/matlab/prior_bounds.m
+++ b/matlab/prior_bounds.m
@@ -47,7 +47,7 @@ function bounds = prior_bounds(bayestopt, prior_trunc)
 % SPECIAL REQUIREMENTS
 %    none
 
-% Copyright © 2003-2017 Dynare Team
+% Copyright © 2003-2023 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -88,17 +88,8 @@ for i=1:length(p6)
             bounds.lb(i) = p3(i);
             bounds.ub(i) = Inf;
         else
-            try
-                bounds.lb(i) = gaminv(prior_trunc,p6(i),p7(i))+p3(i);
-                bounds.ub(i) = gaminv(1-prior_trunc,p6(i),p7(i))+p3(i);
-            catch
-                % Workaround for ticket #161, see http://savannah.gnu.org/bugs/?52569
-                if isoctave
-                    error(['Due to a computational limitation in Octave, the prior bounds cannot be computed. You must either use prior_trunc=0 or choose other values for mean and/or variance of your prior on ' bayestopt.name{i} ', or use another shape'])
-                else
-                    rethrow(lasterror)
-                end
-            end
+            bounds.lb(i) = gaminv(prior_trunc,p6(i),p7(i))+p3(i);
+            bounds.ub(i) = gaminv(1-prior_trunc,p6(i),p7(i))+p3(i);
         end
       case 3
         if prior_trunc == 0
@@ -113,17 +104,8 @@ for i=1:length(p6)
             bounds.lb(i) = p3(i);
             bounds.ub(i) = Inf;
         else
-            try
-                bounds.lb(i) = 1/sqrt(gaminv(1-prior_trunc, p7(i)/2, 2/p6(i)))+p3(i);
-                bounds.ub(i) = 1/sqrt(gaminv(prior_trunc, p7(i)/2, 2/p6(i)))+p3(i);
-            catch
-                % Workaround for ticket #161, see http://savannah.gnu.org/bugs/?52569
-                if isoctave
-                    error(['Due to a computational limitation in Octave, the prior bounds cannot be computed. You must either use prior_trunc=0 or choose other values for mean and/or variance of your prior on ' bayestopt.name{i} ', or use another shape'])
-                else
-                    rethrow(lasterror)
-                end
-            end
+            bounds.lb(i) = 1/sqrt(gaminv(1-prior_trunc, p7(i)/2, 2/p6(i)))+p3(i);
+            bounds.ub(i) = 1/sqrt(gaminv(prior_trunc, p7(i)/2, 2/p6(i)))+p3(i);
         end
       case 5
         if prior_trunc == 0
@@ -138,17 +120,8 @@ for i=1:length(p6)
             bounds.lb(i) = p3(i);
             bounds.ub(i) = Inf;
         else
-            try
-                bounds.lb(i) = 1/gaminv(1-prior_trunc, p7(i)/2, 2/p6(i))+p3(i);
-                bounds.ub(i) = 1/gaminv(prior_trunc, p7(i)/2, 2/p6(i))+ p3(i);
-            catch
-                % Workaround for ticket #161, see http://savannah.gnu.org/bugs/?52569
-                if isoctave
-                    error(['Due to a computational limitation in Octave, the prior bounds cannot be computed. You must either use prior_trunc=0 or choose other values for mean and/or variance of your prior on ' bayestopt.name{i} ', or use another shape'])
-                else
-                    rethrow(lasterror)
-                end
-            end
+            bounds.lb(i) = 1/gaminv(1-prior_trunc, p7(i)/2, 2/p6(i))+p3(i);
+            bounds.ub(i) = 1/gaminv(prior_trunc, p7(i)/2, 2/p6(i))+ p3(i);
         end
       case 8
         if prior_trunc == 0