OUTSET_ROUTINE::ProcessItem(): handle an exception thrown for incorrect prm.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19880
This commit is contained in:
jean-pierre charras 2025-02-07 19:47:48 +01:00
parent 5fda0d02e1
commit dc1ecea4bc
2 changed files with 19 additions and 8 deletions

View File

@ -25,10 +25,11 @@
#include "geometry/roundrect.h" #include "geometry/roundrect.h"
#include <stdexcept> #include <ki_exception.h>
#include <geometry/shape_poly_set.h> #include <geometry/shape_poly_set.h>
#include <geometry/shape_utils.h> #include <geometry/shape_utils.h>
#include <wx/intl.h>
namespace namespace
@ -55,13 +56,13 @@ ROUNDRECT::ROUNDRECT( SHAPE_RECT aRect, int aRadius ) :
{ {
if( m_radius > m_rect.MajorDimension() ) if( m_radius > m_rect.MajorDimension() )
{ {
throw std::invalid_argument( throw KI_PARAM_ERROR(
"Roundrect radius is larger than the rectangle's major dimension" ); _( "Roundrect radius is larger than the rectangle's major dimension" ) );
} }
if( m_radius < 0 ) if( m_radius < 0 )
{ {
throw std::invalid_argument( "Roundrect radius must be non-negative" ); throw KI_PARAM_ERROR( _( "Roundrect radius must be non-negative" ) );
} }
} }

View File

@ -33,6 +33,8 @@
#include <pad.h> #include <pad.h>
#include <pcb_track.h> #include <pcb_track.h>
#include <tools/pcb_tool_utils.h> #include <tools/pcb_tool_utils.h>
#include <confirm.h>
#include <ki_exception.h>
namespace namespace
{ {
@ -907,12 +909,20 @@ void OUTSET_ROUTINE::ProcessItem( BOARD_ITEM& aItem )
SHAPE_RECT rect( box ); SHAPE_RECT rect( box );
if( m_params.roundCorners ) if( m_params.roundCorners )
{
try
{ {
ROUNDRECT rrect( rect, m_params.outsetDistance ); ROUNDRECT rrect( rect, m_params.outsetDistance );
SHAPE_POLY_SET poly; SHAPE_POLY_SET poly;
rrect.TransformToPolygon( poly, 0, ERROR_LOC::ERROR_OUTSIDE ); rrect.TransformToPolygon( poly, 0, ERROR_LOC::ERROR_OUTSIDE );
addPoly( poly ); addPoly( poly );
} }
catch( const KI_PARAM_ERROR& error )
{
DisplayErrorMessage( nullptr, error.What() );
}
}
else else
{ {
addRect( rect ); addRect( rect );