@@ -87,7 +87,7 @@ export class WrapError extends Error {
8787
8888 private static re = new RegExp (
8989 [
90- / ^ (?: [ A - Z a - z _ : ] * ; ) ? W r a p E r r o r : (?< reason > (?: .| \r | \n ) * ) / . source ,
90+ / ^ (?: [ A - Z a - z _ : ( ) ` ] * ; ? " ? ) ? W r a p E r r o r : (?< reason > (?: .| \r | \n ) * ) / . source ,
9191 // there is some padding added to the number of words expected in an error code
9292 / (?: \r \n | \r | \n ) c o d e : (?< code > 1 ? [ 0 - 9 ] { 1 , 2 } | 2 [ 0 - 4 ] [ 0 - 9 ] | 2 5 [ 0 - 5 ] ) (?: [ A - Z ] + ? ) { 1 , 5 } /
9393 . source ,
@@ -99,12 +99,14 @@ export class WrapError extends Error {
9999 . source ,
100100 / (?: (?: \r \n | \r | \n ) u r i R e s o l u t i o n S t a c k : (?< resolutionStack > \[ (?: .| \r | \n ) + ] ) ) ? /
101101 . source ,
102- / (?: (?: \r \n | \r | \n ) { 2 } T h i s e x c e p t i o n w a s c a u s e d b y t h e f o l l o w i n g e x c e p t i o n : (?: \r \n | \r | \n ) (?< cause > (?: .| \r | \n ) + ) ) ? $ /
102+ / (?: (?: \r \n | \r | \n ) { 2 } T h i s e x c e p t i o n w a s c a u s e d b y t h e f o l l o w i n g e x c e p t i o n : (?: \r \n | \r | \n ) (?< cause > (?: .| \r | \n ) + ) ) ? /
103103 . source ,
104+ / " ? $ / . source ,
104105 ] . join ( "" )
105106 ) ;
106107
107108 static parse ( error : string ) : WrapError | undefined {
109+ error = WrapError . sanitizeUnwrappedRustResult ( error ) ;
108110 const delim = "\n\nAnother exception was encountered during execution:\n" ;
109111 const errorStrings = error . split ( delim ) ;
110112
@@ -137,6 +139,19 @@ export class WrapError extends Error {
137139 return `${ this . name } : ${ this . message } ` ;
138140 }
139141
142+ // remove escape characters that may have been added by Rust
143+ private static sanitizeUnwrappedRustResult ( error : string ) : string {
144+ if (
145+ error . startsWith (
146+ '__wrap_abort: called `Result::unwrap()` on an `Err` value: "'
147+ )
148+ ) {
149+ error = error . replace ( / \\ " / g, '"' ) ;
150+ error = error . replace ( / \\ n / g, "\n" ) ;
151+ }
152+ return error ;
153+ }
154+
140155 // parse a single WrapError, where the 'prev' property is undefined
141156 private static _parse (
142157 error : string
0 commit comments