diff --git a/library/HTMLPurifier/AttrTypes.php b/library/HTMLPurifier/AttrTypes.php
index e4429e86..62575ca6 100644
--- a/library/HTMLPurifier/AttrTypes.php
+++ b/library/HTMLPurifier/AttrTypes.php
@@ -77,7 +77,7 @@ class HTMLPurifier_AttrTypes
}
if (!isset($this->info[$type])) {
- trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR);
+ throw new Exception('Cannot retrieve undefined attribute type ' . $type);
return;
}
return $this->info[$type]->make($string);
diff --git a/library/HTMLPurifier/Config.php b/library/HTMLPurifier/Config.php
index e6566e80..37470c8c 100644
--- a/library/HTMLPurifier/Config.php
+++ b/library/HTMLPurifier/Config.php
@@ -898,7 +898,11 @@ class HTMLPurifier_Config
break;
}
}
- trigger_error($msg . $extra, $no);
+ if ($no == E_USER_ERROR) {
+ throw new Exception($msg . $extra);
+ } else {
+ trigger_error($msg . $extra, $no);
+ }
}
/**
diff --git a/library/HTMLPurifier/DoctypeRegistry.php b/library/HTMLPurifier/DoctypeRegistry.php
index acc1d64a..9ad7b4b1 100644
--- a/library/HTMLPurifier/DoctypeRegistry.php
+++ b/library/HTMLPurifier/DoctypeRegistry.php
@@ -86,7 +86,7 @@ class HTMLPurifier_DoctypeRegistry
$doctype = $this->aliases[$doctype];
}
if (!isset($this->doctypes[$doctype])) {
- trigger_error('Doctype ' . htmlspecialchars($doctype) . ' does not exist', E_USER_ERROR);
+ throw new Exception('Doctype ' . htmlspecialchars($doctype) . ' does not exist');
$anon = new HTMLPurifier_Doctype($doctype);
return $anon;
}
diff --git a/library/HTMLPurifier/Encoder.php b/library/HTMLPurifier/Encoder.php
index d4791cc1..8bfaf41d 100644
--- a/library/HTMLPurifier/Encoder.php
+++ b/library/HTMLPurifier/Encoder.php
@@ -390,7 +390,7 @@ class HTMLPurifier_Encoder
$str = self::unsafeIconv($encoding, 'utf-8//IGNORE', $str);
if ($str === false) {
// $encoding is not a valid encoding
- trigger_error('Invalid encoding ' . $encoding, E_USER_ERROR);
+ throw new Exception('Invalid encoding ' . $encoding);
return '';
}
// If the string is bjorked by Shift_JIS or a similar encoding
diff --git a/library/HTMLPurifier/HTMLDefinition.php b/library/HTMLPurifier/HTMLDefinition.php
index 9b7b334d..29ae45c5 100644
--- a/library/HTMLPurifier/HTMLDefinition.php
+++ b/library/HTMLPurifier/HTMLDefinition.php
@@ -264,9 +264,8 @@ class HTMLPurifier_HTMLDefinition extends HTMLPurifier_Definition
if (isset($this->info_content_sets['Block'][$block_wrapper])) {
$this->info_block_wrapper = $block_wrapper;
} else {
- trigger_error(
+ throw new Exception(
'Cannot use non-block element as block wrapper',
- E_USER_ERROR
);
}
diff --git a/library/HTMLPurifier/HTMLModule/Tidy.php b/library/HTMLPurifier/HTMLModule/Tidy.php
index 76fd93a6..bd926dc2 100644
--- a/library/HTMLPurifier/HTMLModule/Tidy.php
+++ b/library/HTMLPurifier/HTMLModule/Tidy.php
@@ -112,9 +112,8 @@ class HTMLPurifier_HTMLModule_Tidy extends HTMLPurifier_HTMLModule
return;
}
if (!isset($this->fixesForLevel[$this->defaultLevel])) {
- trigger_error(
- 'Default level ' . $this->defaultLevel . ' does not exist',
- E_USER_ERROR
+ throw new Exception(
+ 'Default level ' . $this->defaultLevel . ' does not exist'
);
return;
}
@@ -162,8 +161,7 @@ class HTMLPurifier_HTMLModule_Tidy extends HTMLPurifier_HTMLModule
$e->$type = $fix;
break;
default:
- trigger_error("Fix type $type not supported", E_USER_ERROR);
- break;
+ throw new Exception("Fix type $type not supported");
}
}
}