diff --git a/dhscanner-kbapi.cabal b/dhscanner-kbapi.cabal
--- a/dhscanner-kbapi.cabal
+++ b/dhscanner-kbapi.cabal
@@ -28,7 +28,7 @@
     fundamental modifications to the structure or specification
     of code facts.
 
-version:            3.0.0
+version:            3.1.0
 license:            GPL-3.0-only
 license-file:       LICENSE
 author:             OrenGitHub
@@ -56,7 +56,8 @@
         WithComments,
         WithDataFlowPath,
         WithSanitizers,
-        WithDBReads
+        WithDBReads,
+        QueryError
 
     build-depends:
         aeson >= 2.2 && < 2.4,
diff --git a/json-schema-creator/Main.hs b/json-schema-creator/Main.hs
--- a/json-schema-creator/Main.hs
+++ b/json-schema-creator/Main.hs
@@ -32,6 +32,7 @@
 import qualified WithDataFlowPath
 import qualified WithSanitizers
 import qualified WithDBReads
+import qualified QueryError
 
 -- every query module names its type Features : qualify the schema name
 qualifiedAs :: String -> SchemaOptions
@@ -95,6 +96,13 @@
 instance ToSchema WithDBReads.Match where declareNamedSchema = genericDeclareNamedSchema (qualifiedAs "WithDBReads")
 instance ToSchema WithDBReads.DBRead
 
+instance ToSchema QueryError.QueryError
+instance ToSchema QueryError.TimeoutContent
+instance ToSchema QueryError.KBNotFoundContent
+instance ToSchema QueryError.BackendInfraProblemsContent
+instance ToSchema QueryError.KBSearchToolNotFoundContent
+instance ToSchema QueryError.KBResponseInvalidSyntaxContent
+
 -- openapi3 ignores tagSingleConstructors : describe the tagged Sanitizer
 -- through a mirror ( drop it once Sanitizer has a second constructor )
 data SanitizerTag = TopLevelIfThenElse deriving ( Generic )
@@ -121,5 +129,7 @@
 main = do
     BL.writeFile "query.schema.json" (encodePretty (schemaWithDefs (Proxy :: Proxy Query)))
     BL.writeFile "query_result.schema.json" (encodePretty (schemaWithDefs (Proxy :: Proxy QueryResult)))
+    BL.writeFile "query_error.schema.json" (encodePretty (schemaWithDefs (Proxy :: Proxy QueryError.QueryError)))
     putStrLn "wrote query.schema.json"
     putStrLn "wrote query_result.schema.json"
+    putStrLn "wrote query_error.schema.json"
diff --git a/src/QueryError.hs b/src/QueryError.hs
new file mode 100644
--- /dev/null
+++ b/src/QueryError.hs
@@ -0,0 +1,83 @@
+{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE DeriveAnyClass #-}
+
+-- |
+--
+-- * The ways a valid 'Kbapi.Query' can fail to produce a 'Kbapi.QueryResult'.
+--
+-- * An empty answer is /not/ an error : no path, no match, no sink are
+--   all 'Kbapi.QueryResult's.
+--
+-- * A request that is not a valid 'Kbapi.Query' is rejected before it
+--   is run, and is not a 'QueryError' either.
+--
+-- * Each details field is free text, written by the query engine for
+--   a human ( or an LLM ) to read : branch on the constructor, never on
+--   the text.
+--
+module QueryError
+
+where
+
+-- general imports
+import GHC.Generics
+import Data.Aeson
+
+data QueryError
+   = Timeout TimeoutContent
+   | KBNotFound KBNotFoundContent
+   | BackendInfraProblems BackendInfraProblemsContent
+   | KBSearchToolNotFound KBSearchToolNotFoundContent
+   | KBResponseInvalidSyntax KBResponseInvalidSyntaxContent
+   deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON )
+
+-- | The HTTP status code a 'QueryError' is returned with.
+--
+-- One clause per constructor, no wildcard : a new constructor without
+-- a code is a compile error ( @-Werror=incomplete-patterns@ ).
+httpResponseCodeOf :: QueryError -> Word
+httpResponseCodeOf (Timeout _)                 = 504
+httpResponseCodeOf (KBNotFound _)              = 404
+httpResponseCodeOf (BackendInfraProblems _)    = 500
+httpResponseCodeOf (KBSearchToolNotFound _)    = 500
+httpResponseCodeOf (KBResponseInvalidSyntax _) = 500
+
+-- | The query did not finish within its time limit.
+data TimeoutContent
+   = TimeoutContent
+     {
+         timeoutDetails :: String
+     }
+     deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON )
+
+-- | No knowledge base was found at the requested location.
+data KBNotFoundContent
+   = KBNotFoundContent
+     {
+         kbNotFoundDetails :: String
+     }
+     deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON )
+
+-- | The search over the knowledge base started, but failed while running.
+data BackendInfraProblemsContent
+   = BackendInfraProblemsContent
+     {
+         backendInfraProblemsDetails :: String
+     }
+     deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON )
+
+-- | The tool that searches the knowledge base could not be started.
+data KBSearchToolNotFoundContent
+   = KBSearchToolNotFoundContent
+     {
+         kbSearchToolNotFoundDetails :: String
+     }
+     deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON )
+
+-- | The search finished, but its answer could not be read back.
+data KBResponseInvalidSyntaxContent
+   = KBResponseInvalidSyntaxContent
+     {
+         kbResponseInvalidSyntaxDetails :: String
+     }
+     deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON )
