Skip to content

Commit

Permalink
Merge branch 'master' into js/documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
redJ4y committed Feb 13, 2023
2 parents 32a207b + 062e459 commit 887cb72
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
19 changes: 19 additions & 0 deletions errors.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

const ERROR_CONSTANTS = [
E_ERROR => "E_ERROR",
E_WARNING => "E_WARNING",
E_PARSE => "E_PARSE",
E_NOTICE => "E_NOTICE",
E_CORE_ERROR => "E_CORE_ERROR",
E_CORE_WARNING => "E_CORE_WARNING",
E_COMPILE_ERROR => "E_COMPILE_ERROR",
E_COMPILE_WARNING => "E_COMPILE_WARNING",
E_USER_ERROR => "E_USER_ERROR",
E_USER_WARNING => "E_USER_WARNING",
E_USER_NOTICE => "E_USER_NOTICE",
E_STRICT => "E_STRICT",
E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR",
E_DEPRECATED => "E_DEPRECATED",
E_USER_DEPRECATED => "E_USER_DEPRECATED",
];
23 changes: 4 additions & 19 deletions main.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

use Raygun\Raygun4WP\RaygunClientManager;

require_once dirname(__FILE__) . '/errors.php';

register_activation_hook(__FILE__, 'rg4wp_install');
register_deactivation_hook(__FILE__, 'rg4wp_uninstall');

Expand Down Expand Up @@ -85,27 +87,10 @@ function rg4wp_js() {
RaygunClientManager::getInstance()->SetVersion(get_bloginfo('version'));

function getErrorTag(int $errno): string {
$errConsts = [
E_ERROR => "E_ERROR",
E_WARNING => "E_WARNING",
E_PARSE => "E_PARSE",
E_NOTICE => "E_NOTICE",
E_CORE_ERROR => "E_CORE_ERROR",
E_CORE_WARNING => "E_CORE_WARNING",
E_COMPILE_ERROR => "E_COMPILE_ERROR",
E_COMPILE_WARNING => "E_COMPILE_WARNING",
E_USER_ERROR => "E_USER_ERROR",
E_USER_WARNING => "E_USER_WARNING",
E_USER_NOTICE => "E_USER_NOTICE",
E_STRICT => "E_STRICT",
E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR",
E_DEPRECATED => "E_DEPRECATED",
E_USER_DEPRECATED => "E_USER_DEPRECATED",
];
if (!array_key_exists($errno, $errConsts)) {
if (!array_key_exists($errno, ERROR_CONSTANTS)) {
return 'unknown-error';
}
return strtolower(str_replace('_', '-', substr($errConsts[$errno], 2)));
return strtolower(str_replace('_', '-', substr(ERROR_CONSTANTS[$errno], 2)));
}

set_error_handler(function ($errno, $errstr, $errfile, $errline) {
Expand Down

0 comments on commit 887cb72

Please sign in to comment.