diff --git a/src/document/crdt/element_rht.ts b/src/document/crdt/element_rht.ts index 53aff4d2e..2c36081b2 100644 --- a/src/document/crdt/element_rht.ts +++ b/src/document/crdt/element_rht.ts @@ -115,9 +115,9 @@ export class ElementRHT { */ public delete(createdAt: TimeTicket, executedAt: TimeTicket): CRDTElement { if (!this.nodeMapByCreatedAt.has(createdAt.toIDString())) { - const ERROR_MESSAGE = `fail to find ${createdAt.toIDString()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to find ${createdAt.toIDString()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } const node = this.nodeMapByCreatedAt.get(createdAt.toIDString())!; @@ -145,11 +145,11 @@ export class ElementRHT { element.getCreatedAt().toIDString(), ); if (!node) { - const ERROR_MESSAGE = `fail to find ${element + const ErrorMessage = `fail to find ${element .getCreatedAt() .toIDString()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } const nodeByKey = this.nodeMapByKey.get(node.getStrKey()); diff --git a/src/document/crdt/rga_tree_list.ts b/src/document/crdt/rga_tree_list.ts index 156775eb2..16146b236 100644 --- a/src/document/crdt/rga_tree_list.ts +++ b/src/document/crdt/rga_tree_list.ts @@ -181,9 +181,9 @@ export class RGATreeList { ): RGATreeListNode { let node = this.nodeMapByCreatedAt.get(createdAt.toIDString()); if (!node) { - const ERROR_MESSAGE = `cant find the given node: ${createdAt.toIDString()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `cant find the given node: ${createdAt.toIDString()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } while ( @@ -235,16 +235,16 @@ export class RGATreeList { ): void { const prevNode = this.nodeMapByCreatedAt.get(prevCreatedAt.toIDString()); if (!prevNode) { - const ERROR_MESSAGE = `cant find the given node: ${prevCreatedAt.toIDString()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `cant find the given node: ${prevCreatedAt.toIDString()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } const node = this.nodeMapByCreatedAt.get(createdAt.toIDString()); if (!node) { - const ERROR_MESSAGE = `cant find the given node: ${createdAt.toIDString()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `cant find the given node: ${createdAt.toIDString()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } if ( @@ -291,11 +291,11 @@ export class RGATreeList { element.getCreatedAt().toIDString(), ); if (!node) { - const ERROR_MESSAGE = `fail to find the given createdAt: ${element + const ErrorMessage = `fail to find the given createdAt: ${element .getCreatedAt() .toIDString()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } this.release(node!); } diff --git a/src/document/crdt/rga_tree_split.ts b/src/document/crdt/rga_tree_split.ts index 122788878..4c2558f45 100644 --- a/src/document/crdt/rga_tree_split.ts +++ b/src/document/crdt/rga_tree_split.ts @@ -635,9 +635,9 @@ export class RGATreeSplit implements GCParent { ? this.findFloorNodePreferToLeft(absoluteID) : this.findFloorNode(absoluteID); if (!node) { - const ERROR_MESSAGE = `the node of the given id should be found: ${absoluteID.toTestString()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `the node of the given id should be found: ${absoluteID.toTestString()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } const index = this.treeByIndex.indexOf(node!); const offset = node!.isRemoved() @@ -794,9 +794,9 @@ export class RGATreeSplit implements GCParent { ): RGATreeSplitNode { let node = this.findFloorNode(id); if (!node) { - const ERROR_MESSAGE = `the node of the given id should be found: ${id.toTestString()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `the node of the given id should be found: ${id.toTestString()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } if (id.getOffset() > 0 && node!.getID().getOffset() == id.getOffset()) { @@ -848,9 +848,9 @@ export class RGATreeSplit implements GCParent { offset: number, ): RGATreeSplitNode | undefined { if (offset > node.getContentLength()) { - const ERROR_MESSAGE = `offset should be less than or equal to length`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `offset should be less than or equal to length`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } if (offset === 0) { diff --git a/src/document/crdt/root.ts b/src/document/crdt/root.ts index 4dea28e23..2a31907d7 100644 --- a/src/document/crdt/root.ts +++ b/src/document/crdt/root.ts @@ -135,9 +135,9 @@ export class CRDTRoot { const createdAt = pair.element.getCreatedAt(); const subPath = pair.parent.subPathOf(createdAt); if (subPath === undefined) { - const ERROR_MESSAGE = `cant find the given element: ${createdAt.toIDString()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `cant find the given element: ${createdAt.toIDString()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } subPaths.unshift(subPath!); diff --git a/src/document/json/counter.ts b/src/document/json/counter.ts index b3bf65094..f7333de72 100644 --- a/src/document/json/counter.ts +++ b/src/document/json/counter.ts @@ -79,9 +79,9 @@ export class Counter { */ public increase(v: number | Long): Counter { if (!this.context || !this.counter) { - const ERROR_MESSAGE = 'Counter is not initialized yet'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE); + const ErrorMessage = 'Counter is not initialized yet'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage); } const ticket = this.context.issueTimeTicket(); diff --git a/src/document/json/text.ts b/src/document/json/text.ts index f341e8e06..783a64a3b 100644 --- a/src/document/json/text.ts +++ b/src/document/json/text.ts @@ -93,15 +93,15 @@ export class Text { attributes?: A, ): [number, number] | undefined { if (!this.context || !this.text) { - const ERROR_MESSAGE = 'Text is not initialized yet'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE); + const ErrorMessage = 'Text is not initialized yet'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage); } if (fromIdx > toIdx) { - const ERROR_MESSAGE = 'from should be less than or equal to to'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = 'from should be less than or equal to to'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } const range = this.text.indexRangeToPosRange(fromIdx, toIdx); @@ -157,15 +157,15 @@ export class Text { */ setStyle(fromIdx: number, toIdx: number, attributes: A): boolean { if (!this.context || !this.text) { - const ERROR_MESSAGE = 'Text is not initialized yet'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE); + const ErrorMessage = 'Text is not initialized yet'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage); } if (fromIdx > toIdx) { - const ERROR_MESSAGE = 'from should be less than or equal to to'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = 'from should be less than or equal to to'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } const range = this.text.indexRangeToPosRange(fromIdx, toIdx); @@ -208,9 +208,9 @@ export class Text { */ indexRangeToPosRange(range: [number, number]): TextPosStructRange { if (!this.context || !this.text) { - const ERROR_MESSAGE = 'Text is not initialized yet'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE); + const ErrorMessage = 'Text is not initialized yet'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage); } const textRange = this.text.indexRangeToPosRange(range[0], range[1]); @@ -222,9 +222,9 @@ export class Text { */ posRangeToIndexRange(range: TextPosStructRange): [number, number] { if (!this.context || !this.text) { - const ERROR_MESSAGE = 'Text is not initialized yet'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE); + const ErrorMessage = 'Text is not initialized yet'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage); } const textRange = this.text.findIndexesFromRange([ @@ -240,9 +240,9 @@ export class Text { */ toTestString(): string { if (!this.context || !this.text) { - const ERROR_MESSAGE = 'Text is not initialized yet'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE); + const ErrorMessage = 'Text is not initialized yet'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage); } return this.text.toTestString(); @@ -253,9 +253,9 @@ export class Text { */ values(): Array> { if (!this.context || !this.text) { - const ERROR_MESSAGE = 'Text is not initialized yet'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE); + const ErrorMessage = 'Text is not initialized yet'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage); } return this.text.values(); @@ -290,9 +290,9 @@ export class Text { */ toString(): string { if (!this.context || !this.text) { - const ERROR_MESSAGE = 'Text is not initialized yet'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE); + const ErrorMessage = 'Text is not initialized yet'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage); } return this.text.toString(); @@ -333,9 +333,9 @@ export class Text { */ createRangeForTest(fromIdx: number, toIdx: number): RGATreeSplitPosRange { if (!this.context || !this.text) { - const ERROR_MESSAGE = 'Text is not initialized yet'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE); + const ErrorMessage = 'Text is not initialized yet'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage); } return this.text.indexRangeToPosRange(fromIdx, toIdx); diff --git a/src/document/json/tree.ts b/src/document/json/tree.ts index 9e15f9cac..983da2987 100644 --- a/src/document/json/tree.ts +++ b/src/document/json/tree.ts @@ -739,9 +739,9 @@ export class Tree { range: [Array, Array], ): TreePosStructRange { if (!this.context || !this.tree) { - const ERROR_MESSAGE = 'Tree is not initialized yet'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE); + const ErrorMessage = 'Tree is not initialized yet'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage); } const indexRange: [number, number] = [ @@ -757,9 +757,9 @@ export class Tree { */ indexRangeToPosRange(range: [number, number]): TreePosStructRange { if (!this.context || !this.tree) { - const ERROR_MESSAGE = 'Tree is not initialized yet'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE); + const ErrorMessage = 'Tree is not initialized yet'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage); } return this.tree.indexRangeToPosStructRange(range); @@ -770,9 +770,9 @@ export class Tree { */ posRangeToIndexRange(range: TreePosStructRange): [number, number] { if (!this.context || !this.tree) { - const ERROR_MESSAGE = 'Tree is not initialized yet'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE); + const ErrorMessage = 'Tree is not initialized yet'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage); } const posRange: [CRDTTreePos, CRDTTreePos] = [ @@ -790,9 +790,9 @@ export class Tree { range: TreePosStructRange, ): [Array, Array] { if (!this.context || !this.tree) { - const ERROR_MESSAGE = 'Tree is not initialized yet'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE); + const ErrorMessage = 'Tree is not initialized yet'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage); } const posRange: [CRDTTreePos, CRDTTreePos] = [ diff --git a/src/document/operation/add_operation.ts b/src/document/operation/add_operation.ts index 9167c3897..3526b7e3a 100644 --- a/src/document/operation/add_operation.ts +++ b/src/document/operation/add_operation.ts @@ -61,14 +61,14 @@ export class AddOperation extends Operation { public execute(root: CRDTRoot): ExecutionResult { const parentObject = root.findByCreatedAt(this.getParentCreatedAt()); if (!parentObject) { - const ERROR_MESSAGE = `fail to find ${this.getParentCreatedAt()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to find ${this.getParentCreatedAt()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } if (!(parentObject instanceof CRDTArray)) { - const ERROR_MESSAGE = `fail to execute, only array can execute add`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to execute, only array can execute add`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } const array = parentObject as CRDTArray; const value = this.value.deepcopy(); diff --git a/src/document/operation/edit_operation.ts b/src/document/operation/edit_operation.ts index d86479473..491d6314d 100644 --- a/src/document/operation/edit_operation.ts +++ b/src/document/operation/edit_operation.ts @@ -84,14 +84,14 @@ export class EditOperation extends Operation { public execute(root: CRDTRoot): ExecutionResult { const parentObject = root.findByCreatedAt(this.getParentCreatedAt()); if (!parentObject) { - const ERROR_MESSAGE = `fail to find ${this.getParentCreatedAt()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to find ${this.getParentCreatedAt()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } if (!(parentObject instanceof CRDTText)) { - const ERROR_MESSAGE = `fail to execute, only Text can execute edit`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to execute, only Text can execute edit`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } const text = parentObject as CRDTText; diff --git a/src/document/operation/increase_operation.ts b/src/document/operation/increase_operation.ts index 01d519f00..7dab3bcb0 100644 --- a/src/document/operation/increase_operation.ts +++ b/src/document/operation/increase_operation.ts @@ -63,14 +63,14 @@ export class IncreaseOperation extends Operation { public execute(root: CRDTRoot): ExecutionResult { const parentObject = root.findByCreatedAt(this.getParentCreatedAt()); if (!parentObject) { - const ERROR_MESSAGE = `fail to find ${this.getParentCreatedAt()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to find ${this.getParentCreatedAt()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } if (!(parentObject instanceof CRDTCounter)) { - const ERROR_MESSAGE = `fail to execute, only Counter can execute increase`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to execute, only Counter can execute increase`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } const counter = parentObject as CRDTCounter; const value = this.value.deepcopy() as Primitive; diff --git a/src/document/operation/move_operation.ts b/src/document/operation/move_operation.ts index 873d11860..2b8573136 100644 --- a/src/document/operation/move_operation.ts +++ b/src/document/operation/move_operation.ts @@ -65,14 +65,14 @@ export class MoveOperation extends Operation { public execute(root: CRDTRoot): ExecutionResult { const parentObject = root.findByCreatedAt(this.getParentCreatedAt()); if (!parentObject) { - const ERROR_MESSAGE = `fail to find ${this.getParentCreatedAt()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to find ${this.getParentCreatedAt()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } if (!(parentObject instanceof CRDTArray)) { - const ERROR_MESSAGE = `fail to execute, only array can execute move`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to execute, only array can execute move`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } const array = parentObject as CRDTArray; const previousIndex = Number(array.subPathOf(this.createdAt)); diff --git a/src/document/operation/remove_operation.ts b/src/document/operation/remove_operation.ts index 8a52a73e0..5b92043c3 100644 --- a/src/document/operation/remove_operation.ts +++ b/src/document/operation/remove_operation.ts @@ -69,14 +69,14 @@ export class RemoveOperation extends Operation { this.getParentCreatedAt(), ) as CRDTContainer; if (!container) { - const ERROR_MESSAGE = `fail to find ${this.getParentCreatedAt()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to find ${this.getParentCreatedAt()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } if (!(container instanceof CRDTContainer)) { - const ERROR_MESSAGE = `only object and array can execute remove: ${container}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `only object and array can execute remove: ${container}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } // NOTE(chacha912): Handle cases where operation cannot be executed during undo and redo. diff --git a/src/document/operation/set_operation.ts b/src/document/operation/set_operation.ts index 1c22ce7b0..2c32769ee 100644 --- a/src/document/operation/set_operation.ts +++ b/src/document/operation/set_operation.ts @@ -67,14 +67,14 @@ export class SetOperation extends Operation { ): ExecutionResult | undefined { const obj = root.findByCreatedAt(this.getParentCreatedAt()) as CRDTObject; if (!obj) { - const ERROR_MESSAGE = `fail to find ${this.getParentCreatedAt()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to find ${this.getParentCreatedAt()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } if (!(obj instanceof CRDTObject)) { - const ERROR_MESSAGE = `fail to execute, only object can execute set`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to execute, only object can execute set`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } // NOTE(chacha912): Handle cases where operation cannot be executed during undo and redo. diff --git a/src/document/operation/style_operation.ts b/src/document/operation/style_operation.ts index 0d815e311..ab5945a38 100644 --- a/src/document/operation/style_operation.ts +++ b/src/document/operation/style_operation.ts @@ -78,14 +78,14 @@ export class StyleOperation extends Operation { public execute(root: CRDTRoot): ExecutionResult { const parentObject = root.findByCreatedAt(this.getParentCreatedAt()); if (!parentObject) { - const ERROR_MESSAGE = `fail to find ${this.getParentCreatedAt()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to find ${this.getParentCreatedAt()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } if (!(parentObject instanceof CRDTText)) { - const ERROR_MESSAGE = `fail to execute, only Text can execute edit`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to execute, only Text can execute edit`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } const text = parentObject as CRDTText; const [, pairs, changes] = text.setStyle( diff --git a/src/document/operation/tree_edit_operation.ts b/src/document/operation/tree_edit_operation.ts index 86f1f92af..662566586 100644 --- a/src/document/operation/tree_edit_operation.ts +++ b/src/document/operation/tree_edit_operation.ts @@ -86,14 +86,14 @@ export class TreeEditOperation extends Operation { public execute(root: CRDTRoot): ExecutionResult { const parentObject = root.findByCreatedAt(this.getParentCreatedAt()); if (!parentObject) { - const ERROR_MESSAGE = `fail to find ${this.getParentCreatedAt()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to find ${this.getParentCreatedAt()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } if (!(parentObject instanceof CRDTTree)) { - const ERROR_MESSAGE = `fail to execute, only Tree can execute edit`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to execute, only Tree can execute edit`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } const editedAt = this.getExecutedAt(); const tree = parentObject as CRDTTree; diff --git a/src/document/operation/tree_style_operation.ts b/src/document/operation/tree_style_operation.ts index 7dfe5852a..65b0e68d9 100644 --- a/src/document/operation/tree_style_operation.ts +++ b/src/document/operation/tree_style_operation.ts @@ -108,14 +108,14 @@ export class TreeStyleOperation extends Operation { public execute(root: CRDTRoot): ExecutionResult { const parentObject = root.findByCreatedAt(this.getParentCreatedAt()); if (!parentObject) { - const ERROR_MESSAGE = `fail to find ${this.getParentCreatedAt()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to find ${this.getParentCreatedAt()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } if (!(parentObject instanceof CRDTTree)) { - const ERROR_MESSAGE = `fail to execute, only Tree can execute edit`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `fail to execute, only Tree can execute edit`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } const tree = parentObject as CRDTTree; let changes: Array; diff --git a/src/util/observable.ts b/src/util/observable.ts index 810773af7..efe35883c 100644 --- a/src/util/observable.ts +++ b/src/util/observable.ts @@ -107,15 +107,15 @@ class ObserverProxy implements Observer { let observer: Observer; if (!nextOrObserver) { - const ERROR_MESSAGE = 'missing observer'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = 'missing observer'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } if (this.finalized) { - const ERROR_MESSAGE = 'observable is finalized due to previous error'; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrOperationNotPermitted, ERROR_MESSAGE); + const ErrorMessage = 'observable is finalized due to previous error'; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrOperationNotPermitted, ErrorMessage); } if (typeof nextOrObserver === 'object') { diff --git a/src/util/splay_tree.ts b/src/util/splay_tree.ts index 888d1b2bf..bac9c38e6 100644 --- a/src/util/splay_tree.ts +++ b/src/util/splay_tree.ts @@ -207,9 +207,9 @@ export class SplayTree { } } if (pos > node.getLength()) { - const ERROR_MESSAGE = `out of index range: pos: ${pos} > node.length: ${node.getLength()}`; - logger.fatal(ERROR_MESSAGE); - throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE); + const ErrorMessage = `out of index range: pos: ${pos} > node.length: ${node.getLength()}`; + logger.fatal(ErrorMessage); + throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage); } return [node, pos]; } diff --git a/test/integration/primitive_test.ts b/test/integration/primitive_test.ts index 575c0ce4a..5211cb29c 100644 --- a/test/integration/primitive_test.ts +++ b/test/integration/primitive_test.ts @@ -36,11 +36,11 @@ describe('Primitive', function () { }); assert.equal('{"k1":{"k1-1":1,"k1-2":2}}', doc.toSortedJSON()); assert.throws(() => { - const ERROR_MESSAGE = 'dummy error'; + const ErrorMessage = 'dummy error'; doc.update((root) => { delete root['k1']['k1-1']; - throw new YorkieError(Code.ErrDummy, ERROR_MESSAGE); - }, ERROR_MESSAGE); + throw new YorkieError(Code.ErrDummy, ErrorMessage); + }, ErrorMessage); }); assert.equal('{"k1":{"k1-1":1,"k1-2":2}}', doc.toSortedJSON()); });