mirror of
https://github.com/swc-project/swc.git
synced 2024-12-30 00:52:29 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
33 lines
815 B
TypeScript
33 lines
815 B
TypeScript
// Loaded from https://deno.land/x/mysql/src/packets/parsers/err.ts
|
|
|
|
|
|
import type { BufferReader } from "../../buffer.ts";
|
|
import type { Connection } from "../../connection.ts";
|
|
import ServerCapabilities from "../../constant/capabilities.ts";
|
|
|
|
/** @ignore */
|
|
export interface ErrorPacket {
|
|
code: number;
|
|
sqlStateMarker?: number;
|
|
sqlState?: number;
|
|
message: string;
|
|
}
|
|
|
|
/** @ignore */
|
|
export function parseError(
|
|
reader: BufferReader,
|
|
conn: Connection,
|
|
): ErrorPacket {
|
|
const code = reader.readUint16();
|
|
const packet: ErrorPacket = {
|
|
code,
|
|
message: "",
|
|
};
|
|
if (conn.capabilities & ServerCapabilities.CLIENT_PROTOCOL_41) {
|
|
packet.sqlStateMarker = reader.readUint8();
|
|
packet.sqlState = reader.readUints(5);
|
|
}
|
|
packet.message = reader.readNullTerminatedString();
|
|
return packet;
|
|
}
|