1111#include < string_view>
1212#include < type_traits>
1313
14+ #include " output.h"
15+
1416#if defined(__cpp_lib_bit_cast)
1517#include < bit> // For std::bit_cast.
1618#endif
@@ -546,7 +548,7 @@ inline OutputBuffer encode_into(InputIterator begin, InputIterator end) {
546548 break ;
547549 }
548550 default : {
549- throw std::runtime_error{ " Invalid base64 encoded data" } ;
551+ Output::Warning ( " Invalid base64 encoded data" ) ;
550552 }
551553 }
552554
@@ -574,15 +576,13 @@ inline OutputBuffer decode_into(std::string_view base64Text) {
574576 }
575577
576578 if ((base64Text.size () & 3 ) != 0 ) {
577- throw std::runtime_error{
578- " Invalid base64 encoded data - Size not divisible by 4" };
579+ Output::Warning (" Invalid base64 encoded data - Size not divisible by 4" );
579580 }
580581
581582 const size_t numPadding =
582583 std::count (base64Text.rbegin (), base64Text.rbegin () + 4 , ' =' );
583584 if (numPadding > 2 ) {
584- throw std::runtime_error{
585- " Invalid base64 encoded data - Found more than 2 padding signs" };
585+ Output::Warning (" Invalid base64 encoded data - Found more than 2 padding signs" );
586586 }
587587
588588 const size_t decodedsize = (base64Text.size () * 3 >> 2 ) - numPadding;
@@ -605,8 +605,7 @@ inline OutputBuffer decode_into(std::string_view base64Text) {
605605 const uint32_t temp = d1 | d2 | d3 | d4;
606606
607607 if (temp >= detail::bad_char) {
608- throw std::runtime_error{
609- " Invalid base64 encoded data - Invalid character" };
608+ Output::Warning (" Invalid base64 encoded data - Invalid character" );
610609 }
611610
612611 // Use bit_cast instead of union and type punning to avoid
@@ -636,8 +635,7 @@ inline OutputBuffer decode_into(std::string_view base64Text) {
636635 const uint32_t temp = d1 | d2 | d3;
637636
638637 if (temp >= detail::bad_char) {
639- throw std::runtime_error{
640- " Invalid base64 encoded data - Invalid character" };
638+ Output::Warning (" Invalid base64 encoded data - Invalid character" );
641639 }
642640
643641 // Use bit_cast instead of union and type punning to avoid
@@ -659,8 +657,7 @@ inline OutputBuffer decode_into(std::string_view base64Text) {
659657 const uint32_t temp = d1 | d2;
660658
661659 if (temp >= detail::bad_char) {
662- throw std::runtime_error{
663- " Invalid base64 encoded data - Invalid character" };
660+ Output::Warning (" Invalid base64 encoded data - Invalid character" );
664661 }
665662
666663 const std::array<char , 4 > tempBytes =
@@ -669,8 +666,7 @@ inline OutputBuffer decode_into(std::string_view base64Text) {
669666 break ;
670667 }
671668 default : {
672- throw std::runtime_error{
673- " Invalid base64 encoded data - Invalid padding number" };
669+ Output::Warning (" Invalid base64 encoded data - Invalid padding number" );
674670 }
675671 }
676672
0 commit comments