# Fatal error: Method Kirby\\Editor\\Blocks::\_\_toString() must not throw an exception

**URL:** <https://forum.getkirby.com/t/fatal-error-method-kirby-editor-blocks-tostring-must-not-throw-an-exception/20666>\
**Category:** Questions\
**Created:** [January 6, 2021, 10:20am UTC](https://forum.getkirby.com/t/fatal-error-method-kirby-editor-blocks-tostring-must-not-throw-an-exception/20666 "2021-01-06T10:20:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![demlak](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@demlak](https://forum.getkirby.com/u/demlak)\
**Post date:** [January 6, 2021, 10:20am UTC](https://forum.getkirby.com/t/fatal-error-method-kirby-editor-blocks-tostring-must-not-throw-an-exception/20666/1 "2021-01-06T10:20:13Z")

</div>

ok… this seems to be a little bit complicated on read… the final problem is:  
`$item->text()->blocks()` throws the error, when calling a site with a custom tag, which uses a custom snippet, that i made…

long story:  
i could not upgrade to kirby 3.5 yet… but will in near future… (my used template gets an upgrade soon)

i am using [kirby3-feed](https://github.com/bnomei/kirby3-feed) and [kirby3-video](https://github.com/HashandSalt/kirby3-video) with a custom snippet for videos (i need a player with captions and quality selector - in my case i use [plyr.io](http://plyr.io)):

since i’m not a real- but more a hobby-coder, this code is for sure not good code… but it worked. =)

```auto
<?php
/*
 pattern for video files:
   base-filename-480.m4v
   base-filename-576.m4v
   base-filename-720.m4v
   base-filename-1080.m4v

 pattern for vtt subtitle files (use two digit ISO-639-1 codes!):
   base-filename-de.vtt
   base-filename-en.vtt
   base-filename-fr.vtt

*/

$afterlasthyphen = "/[^-]*$/";
$qualitypattern = "/(\d{3,4})$/";
$cutname = preg_replace($qualitypattern, '', $video->name()) ;

$posterimage = Html::tag('img', null, ['src' => $posterurl, 'alt' => $alt]);
if ($video->siblings()->filterBy('filename', '^=', $cutname)->count() > 1) {
  foreach($video->siblings()->filterBy('filename', '^=', $cutname) as $file) {
      preg_match($qualitypattern, $file->name(), $vidres);
       if ( (!empty($vidres[0])) AND ($file->extension() == $video->extension()) ){
        $videsourcetag .= Html::tag('source', null, ['src' => $file->url(), 'type' => $mime, 'size' => $vidres[0]]);
      } else {
        $videsourcetag = Html::tag('source', null, ['src' => $videourl, 'type' => $mime]);
        }
  }
} else {
  $videsourcetag = Html::tag('source', null, ['src' => $videourl, 'type' => $mime]);
}  

foreach($video->siblings()->filterBy('filename', '^=', $cutname) as $file) {
      if ( $file->extension() == "vtt" ) {
      preg_match($afterlasthyphen, $file->name(), $langsrc);
      $langcode = $langsrc[0];
        $videsourcetag .= Html::tag('track', null, ['kind' => "captions", 'label' => Locale::getDisplayLanguage($langcode, $langcode), 'srclang' => $langcode, 'src' => $file->url(), 'default' => ""]);
      }
  }

$videsourcetag .= Html::tag('a', [$posterimage], ['href' => $videourl]);
$vidtag = Html::tag('video', [$videsourcetag], ['poster' => $posterurl, 'width' => $width, 'height' => $height, 'controls' => $controls, 'preload' => $preload, 'class' => $vidclass]);

if($caption) {
  $cap = Html::tag('figcaption', [$caption]);
} else {
  $cap = null;
}

$vidtag .= $cap;
$player = Html::tag('figure', [$vidtag], ['class' => $class]);

?>

<!-- Embed plyr Player - CSS -->
<?= css([$kirby->url('assets') . '/css/plyr.css']) ?>
<!-- / Embed plyr Player - CSS -->

<!-- Video Player -->
<?= $player ?>

<script type="application/ld+json">
  {
    "@context": "http://schema.org",
    "@type": "VideoObject",
    "name": "<?= $title ?>",
    "description": "<?= $caption ?>",
    "thumbnailUrl": "<?= $posterurl ?>",
    "contentUrl": "<?= $videourl ?>",
    "uploadDate": "<?= $modified ?>"
  }
</script>
<!-- / Video Player -->

<!-- Embed plyr Player - JS -->
<?= js($kirby->url('assets') . '/js/plyr.min.js') ?>

<script>
  // Change the second argument to your options:
  // https://github.com/sampotts/plyr/#options
const players = Array.from(document.querySelectorAll('video')).map(p => new Plyr(p, {
  
controls: [
      'play-large', // The large play button in the center
// 'restart', // Restart playback
// 'rewind', // Rewind by the seek time (default 10 seconds)
      'play', // Play/pause playback
// 'fast-forward', // Fast forward by the seek time (default 10 seconds)
      'progress', // The progress bar and scrubber for playback and buffering
      'current-time', // The current time of playback
      'duration', // The full duration of the media
      'mute', // Toggle mute
      'volume', // Volume control
      'captions', // Toggle captions
      'settings', // Settings menu
// 'download', // Show a download button with a link to either the current source or a custom URL you specify in your options
      'fullscreen', // Toggle fullscreen
      ],

settings: [
 'captions', 
 'quality', 
 'loop',
 ]
}));
// Expose player
//window.player = player;
</script>
<!-- / Embed plyr Player - JS -->

```

now, when using kirby3-feed, to generate a RSS-Feed by parsing my journal entries, i get this error while trying to parse Block fields “`$item->text()->blocks()`” that include the kirbytag for the video (the tag calls the snippet above):

 ![Clipboard01](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/1/158babb76c8627fab4c696040b2ec0b38199ed4c.jpeg)

any idea on that?

---

<div class="post-metadata">

**Author:** ![demlak](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@demlak](https://forum.getkirby.com/u/demlak)\
**Post date:** [January 12, 2021, 8:37am UTC](https://forum.getkirby.com/t/fatal-error-method-kirby-editor-blocks-tostring-must-not-throw-an-exception/20666/2 "2021-01-12T08:37:29Z")

</div>

Just a friendly thread-push =)

---

<div class="post-metadata">

**Author:** ![demlak](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@demlak](https://forum.getkirby.com/u/demlak)\
**Post date:** [January 25, 2021, 12:43am UTC](https://forum.getkirby.com/t/fatal-error-method-kirby-editor-blocks-tostring-must-not-throw-an-exception/20666/3 "2021-01-25T00:43:33Z")

</div>

fixed it by changing `$kirby->url('assets')` to `kirby()->url('assets')`
