@@ -208,7 +208,50 @@ describe('PHP Debug Adapter', () => {
208208 ] ) ;
209209 } ) ;
210210
211- it ( 'should report the error in a virtual error scope' ) ;
211+ it ( 'should report the error in a virtual error scope' , async ( ) => {
212+
213+ await client . setExceptionBreakpointsRequest ( { filters : [ '*' ] } ) ;
214+ const [ , { body : { threadId} } ] = await Promise . all ( [
215+ client . configurationDoneRequest ( ) ,
216+ client . waitForEvent ( 'stopped' ) as Promise < DebugProtocol . StoppedEvent >
217+ ] ) ;
218+
219+ async function assertErrorScope ( name : string , type : string , message : string | RegExp , code ?: string ) {
220+ const frameId = ( await client . stackTraceRequest ( { threadId} ) ) . body . stackFrames [ 0 ] . id ;
221+ const errorScope = ( await client . scopesRequest ( { frameId} ) ) . body . scopes [ 0 ] ;
222+ 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+ }
236+ }
237+
238+ await assertErrorScope ( 'Notice' , 'Notice' , '"Undefined index: undefined_index"' , '8' ) ;
239+ await Promise . all ( [
240+ client . continueRequest ( { threadId} ) ,
241+ client . waitForEvent ( 'stopped' )
242+ ] ) ;
243+ await assertErrorScope ( 'Warning' , 'Warning' , '"Illegal offset type"' , '2' ) ;
244+ await Promise . all ( [
245+ client . continueRequest ( { threadId} ) ,
246+ client . waitForEvent ( 'stopped' )
247+ ] ) ;
248+ await assertErrorScope ( 'Exception' , 'Exception' , '"this is an exception"' ) ;
249+ await Promise . all ( [
250+ client . continueRequest ( { threadId} ) ,
251+ client . waitForEvent ( 'stopped' )
252+ ] ) ;
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 ) * " $ / ) ;
254+ } ) ;
212255 } ) ;
213256
214257 describe ( 'conditional breakpoints' , ( ) => {
0 commit comments