@@ -216,41 +216,56 @@ describe('PHP Debug Adapter', () => {
216216 client . waitForEvent ( 'stopped' ) as Promise < DebugProtocol . StoppedEvent >
217217 ] ) ;
218218
219- async function assertErrorScope ( name : string , type : string , message : string | RegExp , code ?: string ) {
219+ async function getErrorScope ( threadId : number ) : Promise < { name : string , type ? : string , message ? : string , code ?: string } > {
220220 const frameId = ( await client . stackTraceRequest ( { threadId} ) ) . body . stackFrames [ 0 ] . id ;
221221 const errorScope = ( await client . scopesRequest ( { frameId} ) ) . body . scopes [ 0 ] ;
222222 assert . propertyVal ( errorScope , 'name' , name ) ;
223- const errorInfo = ( await client . variablesRequest ( { variablesReference : errorScope . variablesReference } ) ) . body . variables ;
224- const actualType = errorInfo . find ( variable => variable . name === 'type' ) ;
225- const actualMessage = errorInfo . find ( variable => variable . name === 'message' ) ;
226- const actualCode = errorInfo . find ( variable => variable . name === 'code' ) ;
227- assert . propertyVal ( actualType , 'value' , type ) ;
228- if ( message instanceof RegExp ) {
229- assert . match ( actualMessage . value , message ) ;
230- } else {
231- assert . propertyVal ( actualMessage , 'value' , message ) ;
232- }
233- if ( code ) {
234- assert . propertyVal ( actualCode , 'value' , code ) ;
235- }
223+ const variables = ( await client . variablesRequest ( { variablesReference : errorScope . variablesReference } ) ) . body . variables ;
224+ const type = variables . find ( variable => variable . name === 'type' ) ;
225+ const message = variables . find ( variable => variable . name === 'message' ) ;
226+ const code = variables . find ( variable => variable . name === 'code' ) ;
227+ return {
228+ name : errorScope . name ,
229+ type : type && type . value ,
230+ message : message && message . value ,
231+ code : code && code . value
232+ } ;
236233 }
237-
238- await assertErrorScope ( 'Notice' , 'Notice' , '"Undefined index: undefined_index"' , '8' ) ;
234+ assert . deepEqual ( await getErrorScope ( threadId ) , {
235+ name : 'Notice' ,
236+ type : 'Notice' ,
237+ message : '"Undefined index: undefined_index"' ,
238+ code : '8'
239+ } ) ;
239240 await Promise . all ( [
240241 client . continueRequest ( { threadId} ) ,
241242 client . waitForEvent ( 'stopped' )
242243 ] ) ;
243- await assertErrorScope ( 'Warning' , 'Warning' , '"Illegal offset type"' , '2' ) ;
244+ assert . deepEqual ( await getErrorScope ( threadId ) , {
245+ name : 'Warning' ,
246+ type : 'Warning' ,
247+ message : '"Illegal offset type"' ,
248+ code : '2'
249+ } ) ;
244250 await Promise . all ( [
245251 client . continueRequest ( { threadId} ) ,
246252 client . waitForEvent ( 'stopped' )
247253 ] ) ;
248- await assertErrorScope ( 'Exception' , 'Exception' , '"this is an exception"' ) ;
254+ assert . deepEqual ( await getErrorScope ( threadId ) , {
255+ name : 'Exception' ,
256+ type : 'Exception' ,
257+ message : '"this is an exception"'
258+ } ) ;
249259 await Promise . all ( [
250260 client . continueRequest ( { threadId} ) ,
251261 client . waitForEvent ( 'stopped' )
252262 ] ) ;
253- await assertErrorScope ( 'Fatal error' , 'Fatal error' , / ^ " U n c a u g h t E x c e p t i o n : t h i s i s a n e x c e p t i o n ( .| \s ) * " $ / ) ;
263+ const fatalErrorScope = await getErrorScope ( threadId ) ;
264+ assert . propertyVal ( fatalErrorScope , 'name' , 'Fatal error' ) ;
265+ assert . propertyVal ( fatalErrorScope , 'type' , 'Fatal error' ) ;
266+ assert . match ( fatalErrorScope . message , / ^ " U n c a u g h t E x c e p t i o n / ) ;
267+ assert . match ( fatalErrorScope . message , / t h i s i s a n e x c e p t i o n / ) ;
268+ assert . match ( fatalErrorScope . message , / " $ / ) ;
254269 } ) ;
255270 } ) ;
256271
0 commit comments