diff --git a/lib/SimpleSAML/Error/ErrorCodes.php b/lib/SimpleSAML/Error/ErrorCodes.php
index f581cef8fd1066565b4dfbf4c4ea92c3943d2c11..9f5fbc8e18f893112ddbc41cb273e9e9fc680f71 100644
--- a/lib/SimpleSAML/Error/ErrorCodes.php
+++ b/lib/SimpleSAML/Error/ErrorCodes.php
@@ -11,7 +11,6 @@ use SimpleSAML\Locale\Translate;
  *
  * @package SimpleSAMLphp
  */
-
 class ErrorCodes
 {
     /**
@@ -160,8 +159,12 @@ class ErrorCodes
      */
     public static function getErrorCodeTitle(string $errorCode): string
     {
-        $errorCodeTitles = self::getAllErrorCodeTitles();
-        return $errorCodeTitles[$errorCode];
+        if (array_key_exists($errorCode, self::getAllErrorCodeTitles())) {
+            $errorCodeTitles = self::getAllErrorCodeTitles();
+            return $errorCodeTitles[$errorCode];
+        } else {
+            return Translate::addTagPrefix($errorCode, 'title_');
+        }
     }
 
 
@@ -174,8 +177,12 @@ class ErrorCodes
      */
     public static function getErrorCodeDescription(string $errorCode): string
     {
-        $errorCodeDescriptions = self::getAllErrorCodeDescriptions();
-        return $errorCodeDescriptions[$errorCode];
+        if (array_key_exists($errorCode, self::getAllErrorCodeTitles())) {
+            $errorCodeDescriptions = self::getAllErrorCodeDescriptions();
+            return $errorCodeDescriptions[$errorCode];
+        } else {
+            return Translate::addTagPrefix($errorCode, 'descr_');
+        }
     }
 
 
diff --git a/lib/SimpleSAML/Locale/Translate.php b/lib/SimpleSAML/Locale/Translate.php
index be9ac59ed704537a8c8f46956df4476644824879..9285aaf90eb81dbf7efc6dde406d9c75a9a1d436 100644
--- a/lib/SimpleSAML/Locale/Translate.php
+++ b/lib/SimpleSAML/Locale/Translate.php
@@ -58,7 +58,7 @@ class Translate
      * Constructor
      *
      * @param \SimpleSAML\Configuration $configuration Configuration object
-     * @param string|null               $defaultDictionary The default dictionary where tags will come from.
+     * @param string|null $defaultDictionary The default dictionary where tags will come from.
      */
     public function __construct(Configuration $configuration, ?string $defaultDictionary = null)
     {
@@ -218,7 +218,7 @@ class Translate
     /**
      * Mark a string for translation without translating it.
      *
-     * @param string  $tag A tag name to mark for translation.
+     * @param string $tag A tag name to mark for translation.
      *
      * @return string The tag, unchanged.
      */
@@ -234,7 +234,7 @@ class Translate
      * or in metadata.
      *
      * @param string $tag The tag that has a translation
-     * @param mixed  $translation The translation array
+     * @param mixed $translation The translation array
      *
      * @throws \Exception If $translation is neither a string nor an array.
      */
@@ -256,7 +256,7 @@ class Translate
     /**
      * Include a language file from the dictionaries directory.
      *
-     * @param string                         $file File name of dictionary to include
+     * @param string $file File name of dictionary to include
      * @param \SimpleSAML\Configuration|null $otherConfig Optionally provide a different configuration object than the
      * one provided in the constructor to be used to find the directory of the dictionary. This allows to combine
      * dictionaries inside the SimpleSAMLphp main code distribution together with external dictionaries. Defaults to
@@ -449,4 +449,21 @@ class Translate
         // nothing we can use, return null so that we can set a default
         return null;
     }
+
+    /**
+     * Prefix tag
+     *
+     * @param string $tag Translation tag
+     * @param string $prefix Prefix to be added
+     *
+     * @return string Prefixed tag
+     */
+    public static function addTagPrefix(string $tag, string $prefix): string
+    {
+        $tagPos = strrpos($tag, ':');
+        // if tag contains ':' target actual tag
+        $tagPos = ($tagPos === false) ? 0 : $tagPos + 1;
+        // add prefix at $tagPos
+        return substr_replace($tag, $prefix, $tagPos, 0);
+    }
 }