(title: string)
| 343 | * @param title Title to use in the error, usually the name of the variable the error proxy will be set for |
| 344 | */ |
| 345 | export function createErrorProxy(title: string): any { |
| 346 | return new Proxy({}, { |
| 347 | // @TODO Make it throw errors for all(?) cases (delete, construct etc.) |
| 348 | get: (target, p) => { |
| 349 | if (p === errorProxySymbol) { return errorProxyValue; } |
| 350 | throw new Error(`You must not get a value from ${title} before it is initialized (property: "${p.toString()}").`); |
| 351 | }, |
| 352 | set: (target, p) => { |
| 353 | throw new Error(`You must not set a value from ${title} before it is initialized (property: "${p.toString()}").`); |
| 354 | }, |
| 355 | }); |
| 356 | } |
| 357 | |
| 358 | /** |
| 359 | * Convert a size (in bytes) to a more human readable format. |
no test coverage detected