getStructuredErrorForConnection method
Returns the last structured error for connectionId, or null when
there is no connection-scoped error information.
Implementation
Future<StructuredError?> getStructuredErrorForConnection(
int connectionId,
) async {
final r = await _sendRequest<StructuredErrorResponse>(
GetStructuredErrorForConnectionRequest(
_nextRequestId(),
connectionId,
),
);
if (r.error != null) return null;
if (r.message.isEmpty && r.sqlStateString == null) return null;
final sqlState = (r.sqlStateString ?? '').codeUnits;
return StructuredError(
message: r.message,
sqlState: sqlState.isNotEmpty ? sqlState : List.filled(5, 0),
nativeCode: r.nativeCode ?? 0,
);
}