@@ -51,9 +51,18 @@ namespace Rcpp{
5151 if ( index == 0 ) {
5252 push_front ( object ) ;
5353 } else {
54- if ( ref.isNULL ( ) ) throw index_out_of_bounds () ;
54+ if ( ref.isNULL ( ) ) {
55+ throw index_out_of_bounds (" Object being inserted into Dotted Pair is null." );
56+ }
57+
58+ if ( static_cast <R_xlen_t>(index) > ::Rf_xlength (ref.get__ ()) ) {
59+ const char * fmt = " Dotted Pair index is out of bounds: "
60+ " [index=%s; extent=%s]." ;
5561
56- if ( static_cast <R_xlen_t>(index) > ::Rf_xlength (ref.get__ ()) ) throw index_out_of_bounds () ;
62+ throw index_out_of_bounds (fmt,
63+ static_cast <R_xlen_t>(index),
64+ ::Rf_xlength (ref.get__()) ) ;
65+ }
5766
5867 size_t i=1 ;
5968 SEXP x = ref.get__ () ;
@@ -70,7 +79,14 @@ namespace Rcpp{
7079 template <typename T>
7180 void DottedPairImpl<CLASS>::replace( const int & index, const T& object ) {
7281 CLASS& ref = static_cast <CLASS&>(*this ) ;
73- if ( static_cast <R_xlen_t>(index) >= ::Rf_xlength (ref.get__ ()) ) throw index_out_of_bounds () ;
82+ if ( static_cast <R_xlen_t>(index) >= ::Rf_xlength (ref.get__ ()) ) {
83+ const char * fmt = " Dotted Pair index is out of bounds: "
84+ " [index=%i; extent=%i]." ;
85+
86+ throw index_out_of_bounds (fmt,
87+ static_cast <R_xlen_t>(index),
88+ ::Rf_xlength (ref.get__()) ) ;
89+ }
7490
7591 Shield<SEXP> x ( pairlist ( object ) );
7692 SEXP y = ref.get__ () ;
@@ -84,7 +100,15 @@ namespace Rcpp{
84100 template <typename CLASS>
85101 void DottedPairImpl<CLASS>::remove( const size_t & index ) {
86102 CLASS& ref = static_cast <CLASS&>(*this ) ;
87- if ( static_cast <R_xlen_t>(index) >= Rf_xlength (ref.get__ ()) ) throw index_out_of_bounds () ;
103+ if ( static_cast <R_xlen_t>(index) >= Rf_xlength (ref.get__ ()) ) {
104+ const char * fmt = " Dotted Pair index is out of bounds: "
105+ " [index=%i; extent=%i]." ;
106+
107+ throw index_out_of_bounds (fmt,
108+ static_cast <R_xlen_t>(index),
109+ ::Rf_xlength (ref.get__()) ) ;
110+ }
111+
88112 if ( index == 0 ){
89113 ref.set__ ( CDR ( ref.get__ () ) ) ;
90114 } else {
0 commit comments