fix: widen all catch blocks from \Exception to \Throwable
PHP 8.3 TypeError and Error extend \Throwable but NOT \Exception, so catch(\Exception) silently drops them — explaining why the generation pipeline fails at the publishing step with no activity log entry. Now every catch in the generation path catches \Throwable and logs the exception class name for diagnostics. Bump to v0.2.7. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -221,9 +221,9 @@ class PRAutoBlogger_Image_Pipeline {
|
||||
'attachment_id' => $attachment_id,
|
||||
'cost_usd' => $image_data['cost_usd'],
|
||||
];
|
||||
} catch ( \Exception $e ) {
|
||||
} catch ( \Throwable $e ) {
|
||||
PRAutoBlogger_Logger::instance()->error(
|
||||
'Image A generation failed: ' . $e->getMessage(),
|
||||
sprintf( 'Image A %s: %s', get_class( $e ), $e->getMessage() ),
|
||||
'image_pipeline'
|
||||
);
|
||||
|
||||
@@ -287,9 +287,9 @@ class PRAutoBlogger_Image_Pipeline {
|
||||
'attachment_id' => $attachment_id,
|
||||
'cost_usd' => $image_data['cost_usd'],
|
||||
];
|
||||
} catch ( \Exception $e ) {
|
||||
} catch ( \Throwable $e ) {
|
||||
PRAutoBlogger_Logger::instance()->error(
|
||||
'Image B generation failed: ' . $e->getMessage(),
|
||||
sprintf( 'Image B %s: %s', get_class( $e ), $e->getMessage() ),
|
||||
'image_pipeline'
|
||||
);
|
||||
|
||||
|
||||
@@ -173,10 +173,10 @@ PROMPT;
|
||||
if ( '' !== $scene ) {
|
||||
return $scene;
|
||||
}
|
||||
} catch ( \Exception $e ) {
|
||||
} catch ( \Throwable $e ) {
|
||||
// LLM failure is not fatal — fall back to rule-based synthesis.
|
||||
PRAutoBlogger_Logger::instance()->warning(
|
||||
'Image prompt LLM rewrite failed, using fallback: ' . $e->getMessage(),
|
||||
sprintf( 'Image prompt LLM rewrite %s, using fallback: %s', get_class( $e ), $e->getMessage() ),
|
||||
'image_prompt_builder'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -124,8 +124,8 @@ class PRAutoBlogger_Pipeline_Runner {
|
||||
$rejected++;
|
||||
PRAutoBlogger_Logger::instance()->info( 'Article rejected by editor: ' . $idea->get_topic(), 'pipeline' );
|
||||
}
|
||||
} catch ( \Exception $e ) {
|
||||
PRAutoBlogger_Logger::instance()->error( 'Failed to generate article for topic "' . $idea->get_topic() . '": ' . $e->getMessage(), 'pipeline' );
|
||||
} catch ( \Throwable $e ) {
|
||||
PRAutoBlogger_Logger::instance()->error( sprintf( 'Article generation %s for "%s": %s', get_class( $e ), $idea->get_topic(), $e->getMessage() ), 'pipeline' );
|
||||
// Continue with next idea — don't let one failure stop the batch.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,8 +168,13 @@ class PRAutoBlogger_Post_Assembler {
|
||||
'publisher'
|
||||
);
|
||||
}
|
||||
} catch ( \Exception $e ) {
|
||||
PRAutoBlogger_Logger::instance()->warning( 'Image pipeline exception for post ' . $post_id . ': ' . $e->getMessage(), 'publisher' );
|
||||
} catch ( \Throwable $e ) {
|
||||
// Catch \Throwable (not just \Exception) so PHP 8 TypeError/Error
|
||||
// doesn't kill the process silently without any log entry.
|
||||
PRAutoBlogger_Logger::instance()->error(
|
||||
sprintf( 'Image pipeline %s for post %d: %s', get_class( $e ), $post_id, $e->getMessage() ),
|
||||
'publisher'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ class PRAutoBlogger_Source_Collector {
|
||||
sprintf( 'Collected %d items from %s (%d new).', count( $data ), $source_type, $inserted ),
|
||||
'collector'
|
||||
);
|
||||
} catch ( \Exception $e ) {
|
||||
PRAutoBlogger_Logger::instance()->error( "Collection from {$source_type} FAILED: " . $e->getMessage(), 'collector' );
|
||||
} catch ( \Throwable $e ) {
|
||||
PRAutoBlogger_Logger::instance()->error( sprintf( 'Collection %s from %s: %s', get_class( $e ), $source_type, $e->getMessage() ), 'collector' );
|
||||
// Continue with other sources — one failure shouldn't stop everything.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user