Skip to content

Commit c248286

Browse files
authored
Merge pull request #69 from clue-labs/retry-markdown
Retry rendering markdown when hitting rate limit / abuse limit
2 parents 0e29f8c + 04933e5 commit c248286

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

config/berti.config.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,23 @@
120120
return $cacheItem->get();
121121
}
122122

123-
$html = $renderer(
124-
$content,
125-
$document,
126-
$documentCollection,
127-
$assetCollection
128-
);
123+
try {
124+
$html = $renderer(
125+
$content,
126+
$document,
127+
$documentCollection,
128+
$assetCollection
129+
);
130+
} catch (\Exception $e) {
131+
echo 'Temporary error, will retry in 60s: ' . $e->getMessage() . PHP_EOL;
132+
sleep(60);
133+
$html = $renderer(
134+
$content,
135+
$document,
136+
$documentCollection,
137+
$assetCollection
138+
);
139+
}
129140

130141
$cacheItem->set($html);
131142
$cache->save($cacheItem);

0 commit comments

Comments
 (0)