From 321690224c65ded9e806b957736ff2412300ed48 Mon Sep 17 00:00:00 2001 From: Steve Gallo Date: Thu, 19 Jan 2017 12:58:46 -0500 Subject: [PATCH 1/2] Wrap filter execution in try/catch block for improved error logging --- classes/ETL/DataEndpoint/JsonFile.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/classes/ETL/DataEndpoint/JsonFile.php b/classes/ETL/DataEndpoint/JsonFile.php index d63c265b0f..9ba57d2a6f 100644 --- a/classes/ETL/DataEndpoint/JsonFile.php +++ b/classes/ETL/DataEndpoint/JsonFile.php @@ -78,12 +78,17 @@ public function parse($returnArray = false) $this->logAndThrowException("No valid filter options specified for '{$this->path}'."); } - // Run the filter process. - $filterProc = ProcessBuilder::create($filterProcArgs)->getProcess(); + try { + // Run the filter process. + $filterProc = ProcessBuilder::create($filterProcArgs)->getProcess(); - $filterProc->run(); - if (! $filterProc->isSuccessful()) { - $this->logAndThrowException('Filter Error: ' . $filterProc->getErrorOutput()); + $filterProc->run(); + if (! $filterProc->isSuccessful()) { + $this->logAndThrowException('Filter Error: ' . $filterProc->getErrorOutput()); + } + } catch (Exception $e) { + $msg = "Filter Error (" . implode(", ", $filterProcArgs) . "): " . $e->getMessage(); + $this->logAndThrowException($msg); } // Parse the filter process's output. From 3aee162ec1c2fc1e224383180ca6e466cd6d1b61 Mon Sep 17 00:00:00 2001 From: Steve Gallo Date: Thu, 19 Jan 2017 13:03:12 -0500 Subject: [PATCH 2/2] Fixed phpcs warnings/errors --- classes/ETL/DataEndpoint/JsonFile.php | 63 +++++++++++++-------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/classes/ETL/DataEndpoint/JsonFile.php b/classes/ETL/DataEndpoint/JsonFile.php index 9ba57d2a6f..8d5495ed8f 100644 --- a/classes/ETL/DataEndpoint/JsonFile.php +++ b/classes/ETL/DataEndpoint/JsonFile.php @@ -15,8 +15,7 @@ use JsonSchema\Validator; use Symfony\Component\Process\ProcessBuilder; -class JsonFile extends StructuredFile -implements iDataEndpoint +class JsonFile extends StructuredFile implements iDataEndpoint { /** * A JSON Schema describing each element in an array-based JSON file. @@ -193,36 +192,36 @@ private function jsonLastErrorMsg($errorCode) $message = ""; switch ( $errorCode ) { - case JSON_ERROR_NONE: - $message = "No error has occurred"; - break; - case JSON_ERROR_DEPTH: - $message = "The maximum stack depth has been exceeded"; - break; - case JSON_ERROR_STATE_MISMATCH: - $message = "Invalid or malformed JSON"; - break; - case JSON_ERROR_CTRL_CHAR: - $message = " Control character error, possibly incorrectly encoded"; - break; - case JSON_ERROR_SYNTAX: - $message = "Syntax error"; - break; - case JSON_ERROR_UTF8: - $message = "Malformed UTF-8 characters, possibly incorrectly encoded"; - break; - case JSON_ERROR_RECURSION: - $message = "One or more recursive references in the value to be encoded"; - break; - case JSON_ERROR_INF_OR_NAN: - $message = "One or more NAN or INF values in the value to be encoded"; - break; - case JSON_ERROR_UNSUPPORTED_TYPE: - $message = "A value of a type that cannot be encoded was given"; - break; - default: - $message = "Unknown error"; - break; + case JSON_ERROR_NONE: + $message = "No error has occurred"; + break; + case JSON_ERROR_DEPTH: + $message = "The maximum stack depth has been exceeded"; + break; + case JSON_ERROR_STATE_MISMATCH: + $message = "Invalid or malformed JSON"; + break; + case JSON_ERROR_CTRL_CHAR: + $message = " Control character error, possibly incorrectly encoded"; + break; + case JSON_ERROR_SYNTAX: + $message = "Syntax error"; + break; + case JSON_ERROR_UTF8: + $message = "Malformed UTF-8 characters, possibly incorrectly encoded"; + break; + case JSON_ERROR_RECURSION: + $message = "One or more recursive references in the value to be encoded"; + break; + case JSON_ERROR_INF_OR_NAN: + $message = "One or more NAN or INF values in the value to be encoded"; + break; + case JSON_ERROR_UNSUPPORTED_TYPE: + $message = "A value of a type that cannot be encoded was given"; + break; + default: + $message = "Unknown error"; + break; } return $message;