Skip to content

Commit 44e67f3

Browse files
committed
New bestEffort error
1 parent 43b1685 commit 44e67f3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/errors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export const ERR_NO_CLIENTS = new Error("No clients provided in DgraphClient constructor");
22
export const ERR_FINISHED = new Error("Transaction has already been committed or discarded");
33
export const ERR_ABORTED = new Error("Transaction has been aborted. Please retry");
4+
export const ERR_BEST_EFFORT_REQUIRED_READ_ONLY = new Error("Best effort only works for read-only queries");
45

56
/**
67
* CustomError is base class used for defining custom error classes.

src/txn.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DgraphClient } from "./client";
2-
import { ERR_ABORTED, ERR_FINISHED } from "./errors";
2+
import { ERR_ABORTED, ERR_FINISHED, ERR_BEST_EFFORT_REQUIRED_READ_ONLY } from "./errors";
33
import { Assigned, Mutation, Request, Response, TxnContext, TxnOptions } from "./types";
44
import {
55
isAbortedError,
@@ -31,8 +31,8 @@ export class Txn {
3131
this.dc = dc;
3232

3333
if (options && options.bestEffort && !options.readOnly) {
34-
this.dc.debug('Best effort only works with read-only queries.');
35-
throw ERR_ABORTED;
34+
this.dc.debug('Client attempted to query using best-effort without setting the transaction to read-only');
35+
throw ERR_BEST_EFFORT_REQUIRED_READ_ONLY;
3636
}
3737

3838
this.ctx = {

0 commit comments

Comments
 (0)