mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-08-02 14:01:59 +08:00
chore: update request error message
This commit is contained in:
@ -23,10 +23,13 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
structure,
|
||||
});
|
||||
}
|
||||
res.status(200).json(tableStructures);
|
||||
} catch (error) {
|
||||
res.status(200).json({
|
||||
data: tableStructures,
|
||||
});
|
||||
} catch (error: any) {
|
||||
res.status(400).json({
|
||||
error: error,
|
||||
message: error.message || "Failed to get database schema.",
|
||||
code: error.code || "UNKNOWN",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -21,9 +21,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
try {
|
||||
const connector = newConnector(connection);
|
||||
const result = await connector.execute(db, statement);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
res.status(400).json([]);
|
||||
res.status(200).json({
|
||||
data: result,
|
||||
});
|
||||
} catch (error: any) {
|
||||
res.status(400).json({
|
||||
message: error.message || "Failed to execute statement.",
|
||||
code: error.code || "UNKNOWN",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -15,8 +15,11 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const connector = newConnector(connection);
|
||||
await connector.testConnection();
|
||||
res.status(200).json({});
|
||||
} catch (error) {
|
||||
res.status(400).json({});
|
||||
} catch (error: any) {
|
||||
res.status(400).json({
|
||||
message: error.message || "Failed to test connection.",
|
||||
code: error.code || "UNKNOWN",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user