File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ export class Client extends EventEmitter {
79
79
* @see end
80
80
*/
81
81
82
- public connected : boolean ;
82
+ readonly connected : boolean ;
83
83
84
84
constructor ( dbUrl : string , options ?: ClientOptions ) {
85
85
super ( ) ;
@@ -97,6 +97,8 @@ export class Client extends EventEmitter {
97
97
*/
98
98
99
99
public async connect ( ) : Promise < Client > {
100
+ if ( this . connected ) throw new Error ( "Client has already been connected." ) ;
101
+
100
102
await this . client . connect ( ) ;
101
103
this . connected = true ;
102
104
@@ -117,6 +119,8 @@ export class Client extends EventEmitter {
117
119
*/
118
120
119
121
public async end ( ) : Promise < Client > {
122
+ if ( ! this . connected ) throw new Error ( "Client has not been connected yet." ) ;
123
+
120
124
await this . client . end ( ) ;
121
125
this . connected = false ;
122
126
You can’t perform that action at this time.
0 commit comments