import { IConnection } from '@sqltools/types' ; import { ResponseError } from 'vscode-languageserver' ; class DecoratedException < A > extends ResponseError < A > { constructor ( error , data ) { super ( error . code || - 1 , error . message , { ... error . data , ... data } ) ; this . name = error . name || 'DecoratedException' ; this . stack = error . stack ; } } export default function decorateLSException ( e , { conn } = { } ) { let data = { } ; if ( conn && conn . driver ) { data . driver = conn . driver ; data . driverOptions = { mssqlOptions : conn . mssqlOptions , mysqlOptions : conn . mysqlOptions , pgOptions : conn . pgOptions , oracleOptions : conn . oracleOptions , } ; } return new DecoratedException < typeof e . data > ( e , data ) ; }