Skip to content

Commit 6f33eba

Browse files
authored
Fix fatal error handling in V3 API (#126)
1 parent 81aa780 commit 6f33eba

File tree

7 files changed

+396
-167
lines changed

7 files changed

+396
-167
lines changed

.github/workflows/dart.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414
jobs:
1515
build:
1616
runs-on: ubuntu-latest
17+
timeout-minutes: 10
1718

1819
steps:
1920
- uses: actions/checkout@v3

lib/src/message_window.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Map<int, _ServerMessageFn> _messageTypeMap = {
2929
110: (d) => NoDataMessage(),
3030
116: ParameterDescriptionMessage.new,
3131
$3: (d) => CloseCompleteMessage(),
32+
$N: NoticeMessage.new,
3233
};
3334

3435
class MessageFramer {

lib/src/server_messages.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import 'types.dart';
1111

1212
abstract class ServerMessage extends BaseMessage {}
1313

14-
class ErrorResponseMessage implements ServerMessage {
14+
sealed class ErrorOrNoticeMessage implements ServerMessage {
1515
final fields = <ErrorField>[];
1616

17-
ErrorResponseMessage(Uint8List bytes) {
17+
ErrorOrNoticeMessage(Uint8List bytes) {
1818
final reader = ByteDataReader()..add(bytes);
1919

2020
int? identificationToken;
@@ -39,6 +39,10 @@ class ErrorResponseMessage implements ServerMessage {
3939
}
4040
}
4141

42+
class ErrorResponseMessage extends ErrorOrNoticeMessage {
43+
ErrorResponseMessage(super.bytes);
44+
}
45+
4246
class AuthenticationMessage implements ServerMessage {
4347
static const int KindOK = 0;
4448
static const int KindKerberosV5 = 2;
@@ -244,6 +248,10 @@ class NoDataMessage extends ServerMessage {
244248
String toString() => 'No Data Message';
245249
}
246250

251+
class NoticeMessage extends ErrorOrNoticeMessage {
252+
NoticeMessage(super.bytes);
253+
}
254+
247255
/// Identifies the message as a Start Copy Both response.
248256
/// This message is used only for Streaming Replication.
249257
class CopyBothResponseMessage implements ServerMessage {

0 commit comments

Comments
 (0)