Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/Organic/SDK/OrganicSdk.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,9 @@ private function runQuery( $query, array $variables = [] ) {

return $result->getResults();
} catch ( QueryError $e ) {
throw new RuntimeException( 'Organic API Failed', -1, $e );
// Variable is encoded this way so we get more context in Sentry
$query_error_details = json_encode( $e->getErrorDetails() );
throw new RuntimeException( 'Organic API Failed with ' . count( json_decode( $query_error_details ) . ' errors' ), -1, $e );
}
}

Expand All @@ -587,16 +589,15 @@ public function updateToken( $token ) {
*
* @param $array
* @param $dataType
* @throws InvalidArgumentException if a required value is missing
* @return object[]
*/
private function metaArrayToObjects( $array, $dataType ) {
private function metaArrayToObjects( $array, $dataType ): array {
$objects = [];

foreach ( $array as $value ) {
if ( ! isset( $value['externalId'] ) || ! isset( $value['name'] ) ) {
throw new InvalidArgumentException(
'Missing externalId or name attribute in ' . $dataType
);
$value['name'] = $value['name'] ?? $value['email'] ?? '(not set)';
if ( ! isset( $value['externalId'] ) ) {
continue;
}
$objects[] = $value;
}
Expand Down
Loading