import {codeframe} from 'putout'; const {stringify} = JSON; const {entries} = Object; export const createError = (help, source, values) => { const argsBoxStart = '\n ╔══\n'; const argsBoxLine = ' ║'; const argsBoxEnd = '\n ╚══\n'; const args = []; for (const [name, value] of entries(values)) { args.push(`${argsBoxLine} ${name} = ${stringify(value) || typeof value}`); } const error = Error(`${help}${argsBoxStart}${args.join('\n')}${argsBoxEnd}`); error.loc = { line: 1, column: 0, }; throw Error( '\n' + codeframe({ source, error, }), ); };