Skip to content

Commit e2d5b2c

Browse files
committed
Refactor error handling in getExcerpt method to return null string if content cannot be parsed
1 parent 53025a7 commit e2d5b2c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Readability.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public function parse(string $content): self
2323
$this->content->parse($content);
2424
} catch (ParseException $e) {
2525
$this->content = null;
26-
error_log('Cannot parse: '.$e->getMessage());
27-
throw new Exception('Cannot parse: '.$e->getMessage());
26+
error_log('Cannot parse: ' . $e->getMessage());
27+
throw new Exception('Cannot parse: ' . $e->getMessage());
2828
}
2929

3030
return $this;
@@ -47,7 +47,7 @@ public function getTitle(): string
4747
*
4848
* @throws Exception
4949
*/
50-
public function getExcerpt(): string
50+
public function getExcerpt(): ?string
5151
{
5252
$this->checkContent();
5353

0 commit comments

Comments
 (0)