{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/errors/compile/index.ts"],"sourcesContent":["import type { Format, Partial } from \"ts-vista\";\n\nimport type { CompilerContext } from \"#/contexts/compiler\";\nimport type { Position } from \"#/errors/common/position\";\nimport type { Span } from \"#/errors/internal\";\n\nimport { getPosition } from \"#/errors/common/position\";\n\ntype CompleteCompileErrorOptions = {\n    context: CompilerContext;\n    span: Span;\n    message: string;\n};\n\ntype CompileErrorOptions = Format<\n    Partial<CompleteCompileErrorOptions, \"message\">\n>;\n\nclass CompileError extends Error {\n    override name: string = CompileError.name;\n\n    constructor(options: CompileErrorOptions) {\n        const message: string = options.message ?? \"Something went wrong\";\n\n        const file: string = options.context.file;\n\n        const position: Position = getPosition(\n            options.context.code,\n            options.span.start,\n        );\n\n        const source: string = `${file}:${position.line}:${position.column}`;\n\n        let result: string = \"\";\n\n        result += `${message}\\n\\n`;\n\n        result += ` --> ${source}\\n`;\n\n        super(result);\n    }\n}\n\nexport type { CompileErrorOptions, CompleteCompileErrorOptions, Span };\nexport { CompileError };\n"],"mappings":";;AAkBA,IAAM,eAAN,MAAM,qBAAqB,MAAM;CAC7B,AAAS,OAAe,aAAa;CAErC,YAAY,SAA8B;EACtC,MAAM,UAAkB,QAAQ,WAAW;EAE3C,MAAM,OAAe,QAAQ,QAAQ;EAErC,MAAM,WAAqB,YACvB,QAAQ,QAAQ,MAChB,QAAQ,KAAK,KACjB;EAEA,MAAM,SAAiB,GAAG,KAAK,GAAG,SAAS,KAAK,GAAG,SAAS;EAE5D,IAAI,SAAiB;EAErB,UAAU,GAAG,QAAQ;EAErB,UAAU,QAAQ,OAAO;EAEzB,MAAM,MAAM;CAChB;AACJ"}