File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed
packages/tailwindcss-intellisense/src Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import normalizePath from 'normalize-path'
17
17
import { withUserEnvironment } from './environment'
18
18
import execa from 'execa'
19
19
import { klona } from 'klona/full'
20
+ import { formatError } from '../lsp/util/formatError'
20
21
21
22
function arraysEqual ( arr1 , arr2 ) {
22
23
return (
@@ -238,7 +239,7 @@ export default async function getClassNames(
238
239
result = await run ( )
239
240
console . log ( 'Initialised successfully.' )
240
241
} catch ( error ) {
241
- console . error ( 'Failed to initialise:' , error )
242
+ console . error ( formatError ( 'Failed to initialise:' , error ) )
242
243
return null
243
244
}
244
245
Original file line number Diff line number Diff line change @@ -36,12 +36,20 @@ import {
36
36
import { createEmitter } from '../lib/emitter'
37
37
import { registerDocumentColorProvider } from './providers/documentColorProvider'
38
38
import { TextDocument } from 'vscode-languageserver-textdocument'
39
+ import { formatError } from './util/formatError'
39
40
40
41
let connection = createConnection ( ProposedFeatures . all )
41
42
const state : State = { enabled : false , emitter : createEmitter ( connection ) }
42
43
let documents = new TextDocuments ( TextDocument )
43
44
let workspaceFolder : string | null
44
45
46
+ console . log = connection . console . log . bind ( connection . console )
47
+ console . error = connection . console . error . bind ( connection . console )
48
+
49
+ process . on ( 'unhandledRejection' , ( e : any ) => {
50
+ connection . console . error ( formatError ( `Unhandled exception` , e ) )
51
+ } )
52
+
45
53
const defaultSettings : Settings = {
46
54
tabSize : 2 ,
47
55
emmetCompletions : false ,
Original file line number Diff line number Diff line change
1
+ // https://github.com/vscode-langservers/vscode-json-languageserver/blob/master/src/utils/runner.ts
2
+ export function formatError ( message : string , err : any ) : string {
3
+ if ( err instanceof Error ) {
4
+ let error = < Error > err
5
+ return `${ message } : ${ error . message } \n${ error . stack } `
6
+ } else if ( typeof err === 'string' ) {
7
+ return `${ message } : ${ err } `
8
+ } else if ( err ) {
9
+ return `${ message } : ${ err . toString ( ) } `
10
+ }
11
+ return message
12
+ }
You can’t perform that action at this time.
0 commit comments