Home

tailwind-ctp-intellisense @b26e122fac4da99238e38dd5ca837a76e87c54cc - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tailwind-ctp-intellisense / packages / tailwindcss-language-server / src / util / error.ts
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { Connection } from 'vscode-languageserver/node'

function toString(err: any, includeStack: boolean = true): string {
  if (err instanceof Error) {
    let error = <Error>err
    return `${error.message}${includeStack ? `\n${error.stack}` : ''}`
  } else if (typeof err === 'string') {
    return err
  } else {
    return err.toString()
  }
}

// https://github.com/vscode-langservers/vscode-json-languageserver/blob/master/src/utils/runner.ts
export function formatError(message: string, err: any, includeStack: boolean = true): string {
  if (err) {
    return `${message}: ${toString(err, includeStack)}`
  }
  return message
}

export function showError(
  connection: Connection,
  err: any,
  message: string = 'Tailwind CSS'
): void {
  console.error(formatError(message, err))
  // if (!(err instanceof SilentError)) {
  //   connection.sendNotification('@/tailwindCSS/error', {
  //     message: formatError(message, err, false),
  //   })
  // }
}

export function SilentError(message: string) {
  this.name = 'SilentError'
  this.message = message
  this.stack = new Error().stack
}
SilentError.prototype = new Error()