| 147 | 'TEST_OPERATION_FAILED'; |
| 148 | |
| 149 | function patchErrorMessageFormatter(message: String, args: Object): string { |
| 150 | const messageParts = [message]; |
| 151 | for (const key in args) { |
| 152 | const value = typeof args[key] === 'object' ? JSON.stringify(args[key], null, 2) : args[key]; // pretty print |
| 153 | if (typeof value !== 'undefined') { |
| 154 | messageParts.push(`${key}: ${value}`); |
| 155 | } |
| 156 | } |
| 157 | return messageParts.join('\n'); |
| 158 | } |
| 159 | export class PatchError extends Error { |
| 160 | constructor(message: string, public name: JsonPatchErrorName, public index?: number, public operation?: any, public tree?: any) { |
| 161 | super(patchErrorMessageFormatter(message, { name, index, operation, tree })); |