From 091e14ceaead0bd3c8fe541aad2a091f8a241f27 Mon Sep 17 00:00:00 2001 From: Vladimir Khramtsov Date: Tue, 19 Jan 2021 11:49:52 +0300 Subject: [PATCH] Improve exception messages in ffi integration --- src/Bicycle/Tesseract/Bridge/FFI.php | 4 ++-- tests/Bicycle/Tesseract/Bridge/FFITest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bicycle/Tesseract/Bridge/FFI.php b/src/Bicycle/Tesseract/Bridge/FFI.php index f62c4cf..947faa1 100644 --- a/src/Bicycle/Tesseract/Bridge/FFI.php +++ b/src/Bicycle/Tesseract/Bridge/FFI.php @@ -39,7 +39,7 @@ public function __construct(Configuration $configuration) try { $libaryPath = $this->configuration->getSharedLibraryPath(); if (empty($libaryPath)) { - throw new Exception\Exception('Problem with connecting library via FFI'); + throw new Exception\Exception('Problem with connecting library via FFI: empty library path'); } /** @var FFI\TesseractInterface ffiInstance */ $this->ffiInstance = \FFI::cdef( @@ -47,7 +47,7 @@ public function __construct(Configuration $configuration) $libaryPath ); } catch (\FFI\Exception $e) { - throw new Exception\Exception('Problem with connecting library via FFI'); + throw new Exception\Exception(sprintf('Problem with connecting library via FFI: %s', $e->getMessage())); } } diff --git a/tests/Bicycle/Tesseract/Bridge/FFITest.php b/tests/Bicycle/Tesseract/Bridge/FFITest.php index ef27b92..0ab9d3a 100644 --- a/tests/Bicycle/Tesseract/Bridge/FFITest.php +++ b/tests/Bicycle/Tesseract/Bridge/FFITest.php @@ -59,7 +59,7 @@ public function testIncorrectConfiguration(): void { $this->isFFIEnabled(); $this->expectException(Exception::class); - $this->expectExceptionMessage('Problem with connecting library via FFI'); + $this->expectExceptionMessage('Problem with connecting library via FFI: empty library path'); $configuration = new Configuration([]); new FFI($configuration); }