Files
prautoblogger/includes/providers/class-image-nsfw-blocked.php
peptiderepo dc86376e8b style(phpcs): resolve 137 residual WordPress-Core violations
- Added phpcs:ignore for class file naming convention (79 violations)
  WordPress.Files.FileName.InvalidClassFileName is a known architectural
  issue — class files use short names without prautoblogger- prefix

- Added phpcs:ignore for ->prepare() table interpolation (56 violations)
  WordPress.DB.PreparedSQL.InterpolatedNotPrepared: dynamic table names
  (prab_generation_logs, prab_cost_logs) require interpolation; ->prepare()
  does not support table name placeholders, only column values

- Fixed file-level docblock positioning (2 violations)
  prautoblogger.php and uninstall.php: moved declare(strict_types=1) before
  file docblock per PHP best practices
2026-04-23 03:23:52 +00:00

47 lines
1.6 KiB
PHP

<?php
// phpcs:ignore WordPress.Files.FileName.InvalidClassFileName -- class naming convention differs from WordPress standard
declare(strict_types=1);
/**
* Exception raised when an image provider rejects a prompt as NSFW.
*
* Image providers (Runware, OpenRouter) return provider-specific error
* shapes when their content filters block a prompt. We catch those shapes
* in each provider and raise this typed exception so the image pipeline
* can distinguish a content-filter rejection from a generic 4xx and
* retry once with a sanitized fallback prompt.
*
* Triggered by: image providers on NSFW-filter rejection.
* Dependencies: None.
*
* @see providers/class-runware-image-provider.php — May raise this.
* @see providers/class-open-router-image-provider.php — May raise this.
* @see core/class-image-nsfw-retry.php — Catches + rebuilds prompt.
*/
class PRAutoBlogger_Image_NSFW_Blocked extends \RuntimeException {
/**
* The raw upstream response body, kept verbatim for log forensics.
*
* @var string
*/
private string $upstream_body;
/**
* @param string $message Human-readable summary.
* @param string $upstream_body Raw response body from the provider.
* @param \Throwable|null $previous Optional previous exception.
*/
public function __construct( string $message, string $upstream_body = '', ?\Throwable $previous = null ) {
parent::__construct( $message, 0, $previous );
$this->upstream_body = $upstream_body;
}
/**
* @return string Raw upstream body (may be empty).
*/
public function get_upstream_body(): string {
return $this->upstream_body;
}
}