Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PsrUtils.php

function PsrUtils::throwOnErrorOrFalse

2 calls to PsrUtils::throwOnErrorOrFalse()
PsrUtils::decoder in vendor/open-telemetry/sdk/Common/Export/Http/PsrUtils.php
PsrUtils::encoder in vendor/open-telemetry/sdk/Common/Export/Http/PsrUtils.php

File

vendor/open-telemetry/sdk/Common/Export/Http/PsrUtils.php, line 158

Class

PsrUtils
@internal

Namespace

OpenTelemetry\SDK\Common\Export\Http

Code

private static function throwOnErrorOrFalse(callable $callable) : callable {
    return static function (...$args) use ($callable) {
        set_error_handler(static function (int $errno, string $errstr, string $errfile, int $errline) : bool {
            throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
        });
        try {
            $result = $callable(...$args);
        } finally {
            restore_error_handler();
        }
        
        /** @phan-suppress-next-line PhanPossiblyUndeclaredVariable */
        if ($result === false) {
            throw new LogicException();
        }
        
        /** @phan-suppress-next-line PhanPossiblyUndeclaredVariable */
        return $result;
    };
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal