<?php try { json_encode("\xB1", JSON_THROW_ON_ERROR); } catch (\Throwable $e) { echo "own throw -> ", get_class($e), ", previous: ", $e->getPrevious() ? get_class($e->getPrevious()) : 'null', "\n"; } class Boom implements JsonSerializable { public function jsonSerialize(): mixed { throw new RuntimeException('thrown inside jsonSerialize()'); } } try { json_encode(new Boom(), JSON_THROW_ON_ERROR); } catch (\Throwable $e) { echo "user throw -> ", get_class($e), ", previous: ", $e->getPrevious() ? get_class($e->getPrevious()) : 'null', "\n"; }
You have javascript disabled. You will not be able to edit any code.