mirror of
https://github.com/Airsequel/AirGQL.git
synced 2025-08-11 09:26:56 +03:00
Explain what the "database or disk is full" error means to the user
This commit is contained in:
parent
faf63f0c6d
commit
5394fcd9bc
3 changed files with 23 additions and 4 deletions
source/AirGQL
|
@ -36,6 +36,7 @@ module AirGQL.Lib (
|
|||
lintTableCreationCode,
|
||||
resolveReferencesConstraintColumns,
|
||||
resolveReferencesConstraint,
|
||||
sqliteErrorToText,
|
||||
)
|
||||
where
|
||||
|
||||
|
@ -689,7 +690,10 @@ lintTable allEntries parsed =
|
|||
|
||||
An optional connection can be used to retrieve the existing db data, which
|
||||
is used for things like resolving implicit references constraints (where
|
||||
the primary key is not explicitly given)
|
||||
the primary key is not explicitly given).
|
||||
|
||||
The connection is optional to allow calling this function on-the-fly when
|
||||
creating the initial table in a databse.
|
||||
-}
|
||||
lintTableCreationCode :: Maybe SS.Connection -> Statement -> IO [Text]
|
||||
lintTableCreationCode connectionMb statement = do
|
||||
|
@ -1309,3 +1313,19 @@ instance FromJSON SQLPost
|
|||
|
||||
instance ToSample AirGQL.Lib.SQLPost where
|
||||
toSamples _ = singleSample $ SQLPost "SELECT * FROM users"
|
||||
|
||||
|
||||
-- | Converts an sql error to text, possibly adding airsequel-specific context.
|
||||
sqliteErrorToText :: SS.SQLError -> Text
|
||||
sqliteErrorToText error =
|
||||
let
|
||||
addendum = case SS.sqlErrorDetails error of
|
||||
"database or disk is full" ->
|
||||
Just $
|
||||
"This might be caused by the database exceeding "
|
||||
<> "the maximum page count for your current plan."
|
||||
_ -> Nothing
|
||||
in
|
||||
show error <> case addendum of
|
||||
Nothing -> ""
|
||||
Just text -> "\n" <> text
|
||||
|
|
|
@ -42,6 +42,7 @@ import AirGQL.Lib (
|
|||
lintTableCreationCode,
|
||||
parseSql,
|
||||
sqlDataToAesonValue,
|
||||
sqliteErrorToText,
|
||||
)
|
||||
import AirGQL.Types.PragmaConf (PragmaConf, getSQLitePragmas)
|
||||
import AirGQL.Types.SqlQueryPostResult (
|
||||
|
@ -150,7 +151,7 @@ sqlQueryPostHandler pragmaConf dbId sqlPost = do
|
|||
P.catches
|
||||
performSqlOperations
|
||||
[ P.Handler $
|
||||
\(error :: SS.SQLError) -> pure $ Left $ show error
|
||||
\(error :: SS.SQLError) -> pure $ Left $ sqliteErrorToText error
|
||||
, P.Handler $
|
||||
\(error :: SS.ResultError) -> pure $ Left $ show error
|
||||
, P.Handler $
|
||||
|
|
|
@ -7,10 +7,8 @@ where
|
|||
|
||||
import Protolude (
|
||||
Bool (True),
|
||||
IO,
|
||||
Int,
|
||||
Integer,
|
||||
pure,
|
||||
show,
|
||||
($),
|
||||
(<>),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue