main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
531 bytes
|
Rev | Line | |
---|
[d565449] | 1 | /**
|
---|
| 2 | * @fileoverview Shared utilities for error messages.
|
---|
| 3 | * @author Josh Goldberg
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | "use strict";
|
---|
| 7 |
|
---|
| 8 | /**
|
---|
| 9 | * Converts a value to a string that may be printed in errors.
|
---|
| 10 | * @param {any} value The invalid value.
|
---|
| 11 | * @param {number} indentation How many spaces to indent
|
---|
| 12 | * @returns {string} The value, stringified.
|
---|
| 13 | */
|
---|
| 14 | function stringifyValueForError(value, indentation) {
|
---|
| 15 | return value ? JSON.stringify(value, null, 4).replace(/\n/gu, `\n${" ".repeat(indentation)}`) : `${value}`;
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | module.exports = { stringifyValueForError };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.