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'
1717import { withUserEnvironment } from './environment'
1818import execa from 'execa'
1919import { klona } from 'klona/full'
20+ import { formatError } from '../lsp/util/formatError'
2021
2122function arraysEqual ( arr1 , arr2 ) {
2223 return (
@@ -238,7 +239,7 @@ export default async function getClassNames(
238239 result = await run ( )
239240 console . log ( 'Initialised successfully.' )
240241 } catch ( error ) {
241- console . error ( 'Failed to initialise:' , error )
242+ console . error ( formatError ( 'Failed to initialise:' , error ) )
242243 return null
243244 }
244245
Original file line number Diff line number Diff line change @@ -36,12 +36,20 @@ import {
3636import { createEmitter } from '../lib/emitter'
3737import { registerDocumentColorProvider } from './providers/documentColorProvider'
3838import { TextDocument } from 'vscode-languageserver-textdocument'
39+ import { formatError } from './util/formatError'
3940
4041let connection = createConnection ( ProposedFeatures . all )
4142const state : State = { enabled : false , emitter : createEmitter ( connection ) }
4243let documents = new TextDocuments ( TextDocument )
4344let workspaceFolder : string | null
4445
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+
4553const defaultSettings : Settings = {
4654 tabSize : 2 ,
4755 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