Skip to content

Commit 9239969

Browse files
committed
Enabler: Throw warning on JSON decode error
1 parent 08d4bd9 commit 9239969

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Enabler.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,15 @@ private function readStorage(): array
268268

269269
try {
270270
return Json::decode(FileSystem::read($file), Json::FORCE_ARRAY);
271-
} catch (JsonException | IOException $e) {
272-
// Yep, no error thrown, it's low-level library, just re-create storage file at next write
271+
} catch (IOException $e) {
272+
// Yep, no error thrown, maybe file not exists
273+
return [];
274+
} catch (JsonException $e) {
275+
trigger_error(
276+
sprintf('%s: JSON Exception during read token file \'%s\': %s', __CLASS__, $file, $e->getMessage()),
277+
E_USER_WARNING
278+
);
279+
// It's low-level library, just re-create storage file at next write
273280
return [];
274281
}
275282
}

0 commit comments

Comments
 (0)