@@ -143,33 +143,28 @@ export class SharedLibCore implements Core {
143143
144144 const inputBuf = Buffer . from ( JSON . stringify ( req ) , "utf8" ) ;
145145
146- try {
147- const nativeResponse = await this . lib . sendMessage ( inputBuf ) ;
146+ const nativeResponse = await this . lib . sendMessage ( inputBuf ) ;
148147
149- if ( ! ( nativeResponse instanceof Uint8Array ) ) {
150- throw new Error (
151- `Native function returned an unexpected type. Expected Uint8Array, got ${ typeof nativeResponse } ` ,
152- ) ;
153- }
148+ if ( ! ( nativeResponse instanceof Uint8Array ) ) {
149+ throw new Error (
150+ `Native function returned an unexpected type. Expected Uint8Array, got ${ typeof nativeResponse } ` ,
151+ ) ;
152+ }
154153
155- const respString = new TextDecoder ( ) . decode ( nativeResponse ) ;
156- const response = JSON . parse ( respString ) as SharedLibResponse ;
154+ const respString = new TextDecoder ( ) . decode ( nativeResponse ) ;
155+ const response = JSON . parse ( respString ) as SharedLibResponse ;
157156
158- if ( response . success ) {
159- const decodedPayload = Buffer . from ( response . payload ) . toString ( "utf8" ) ;
160- // On success, the payload is the actual result string
161- return decodedPayload ;
162- } else {
163- // On failure, convert the error payload to a readable string and throw
164- const errorMessage = Array . isArray ( response . payload )
165- ? String . fromCharCode ( ...response . payload )
166- : JSON . stringify ( response . payload ) ;
157+ if ( response . success ) {
158+ const decodedPayload = Buffer . from ( response . payload ) . toString ( "utf8" ) ;
159+ // On success, the payload is the actual result string
160+ return decodedPayload ;
161+ } else {
162+ // On failure, convert the error payload to a readable string and throw
163+ const errorMessage = Array . isArray ( response . payload )
164+ ? String . fromCharCode ( ...response . payload )
165+ : JSON . stringify ( response . payload ) ;
167166
168- throwError ( errorMessage ) ;
169- }
170- } catch ( e ) {
171- // Catch errors from the native call or from JSON parsing
172- throw e ;
167+ throwError ( errorMessage ) ;
173168 }
174169 }
175170
0 commit comments