Fix language negotiation exception to be standard
authorEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 18 Oct 2022 00:36:44 +0000 (13:36 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 18 Oct 2022 00:36:44 +0000 (13:36 +1300)
Civi/Core/Locale.php

index 9a02cd130d671cc84035bb68200bec87d8567bb8..709a37bcc04edf620fe5e6cb8d2071e6a79db555 100644 (file)
@@ -169,11 +169,12 @@ class Locale {
    *   Ex: `en_US`, `es_ES`, `fr_CA`
    * @return \Civi\Core\Locale
    *   The effective locale specification.
+   * @throws \CRM_Core_Exception
    */
   public static function negotiate(string $preferred): Locale {
     // Create a locale for the requested language
     if (!preg_match(';^[a-z][a-z]_[A-Z][A-Z]$;', $preferred)) {
-      throw new \RuntimeException("Cannot instantiate malformed locale: $preferred");
+      throw new \CRM_Core_Exception("Cannot instantiate malformed locale: $preferred");
     }
 
     $systemDefault = \Civi::settings()->get('lcMessages');