File tree Expand file tree Collapse file tree 1 file changed +13
-18
lines changed
crypto-ffi/bindings/js/src Expand file tree Collapse file tree 1 file changed +13
-18
lines changed Original file line number Diff line number Diff line change 1+ import { CoreCryptoError_Tags , CoreCryptoError as CoreCryptoErrorFfi } from "./index.web" ;
2+
13/**
24 * The error structure produced by our rust code.
35 **/
@@ -24,25 +26,18 @@ export class CoreCryptoError<T extends ErrorType> extends Error {
2426 type ?: T ;
2527
2628 /* eslint @typescript-eslint/no-explicit-any: off */
27- private constructor ( richError : CoreCryptoRichError < T > , ...params : any [ ] ) {
28- super ( richError . message , ...params ) ;
29- Object . setPrototypeOf ( this , new . target . prototype ) ;
30-
31- if ( richError . error_name ) {
32- this . name = richError . error_name ;
33- }
34- if ( richError . error_stack ) {
35- this . errorStack = richError . error_stack ;
29+ private constructor ( richError : unknown ) {
30+ if ( CoreCryptoErrorFfi . instanceOf ( richError ) ) {
31+ switch ( richError . tag ) {
32+ case CoreCryptoError_Tags . E2ei : {
33+ super ( richError . message )
34+ this . errorStack = [ ]
35+ this . context = { e2eiError : richError . inner . e2eiError }
36+ this . type = ErrorType . E2ei
37+ }
38+ }
3639 } else {
37- this . errorStack = [ ] ;
38- }
39- if (
40- richError . context &&
41- richError . type &&
42- Object . values < string > ( ErrorType ) . includes ( richError . type )
43- ) {
44- this . context = richError . context ;
45- this . type = richError . type as T ;
40+ throw Error ( "Unexpected error instance. Context: constructing CoreCryptoError." )
4641 }
4742 }
4843
You can’t perform that action at this time.
0 commit comments