@@ -34,7 +34,7 @@ import {
3434import { lazyContext } from '../context-helpers/internal-context'
3535import type { fromBytes , TypeInfo } from '../encoders'
3636import { uint8ArrayToNumber } from '../encoding-util'
37- import { avmError , avmInvariant , codeError , CodeError } from '../errors'
37+ import { AvmError , avmInvariant , CodeError } from '../errors'
3838import type { DeliberateAny } from '../typescript-helpers'
3939import { asBigInt , asBigUint , asBigUintCls , asBytesCls , asUint64 , asUint8Array , conactUint8Arrays } from '../util'
4040import type { StubBytesCompat } from './primitives'
@@ -301,7 +301,7 @@ const arrayProxyHandler = <TItem>() => ({
301301 const idx = prop ? parseInt ( prop . toString ( ) , 10 ) : NaN
302302 if ( ! isNaN ( idx ) ) {
303303 if ( idx < target . items . length ) return target . items [ idx ]
304- avmError ( 'Index out of bounds' )
304+ throw new AvmError ( 'Index out of bounds' )
305305 } else if ( prop === Symbol . iterator ) {
306306 return target . items [ Symbol . iterator ] . bind ( target . items )
307307 } else if ( prop === 'entries' ) {
@@ -320,7 +320,7 @@ const arrayProxyHandler = <TItem>() => ({
320320 target . setItem ( idx , value )
321321 return true
322322 }
323- avmError ( 'Index out of bounds' )
323+ throw new AvmError ( 'Index out of bounds' )
324324 }
325325
326326 return Reflect . set ( target , prop , value )
@@ -575,7 +575,7 @@ export class DynamicArrayImpl<TItem extends ARC4Encoded> extends DynamicArray<TI
575575 pop ( ) : TItem {
576576 const items = this . items
577577 const popped = items . pop ( )
578- if ( popped === undefined ) avmError ( 'The array is empty' )
578+ if ( popped === undefined ) throw new AvmError ( 'The array is empty' )
579579 return popped
580580 }
581581
@@ -1255,5 +1255,5 @@ export const getArc4Encoded = (value: DeliberateAny): ARC4Encoded => {
12551255 return new StructImpl ( typeInfo , Object . fromEntries ( Object . keys ( value ) . map ( ( x , i ) => [ x , result [ i ] ] ) ) )
12561256 }
12571257
1258- throw codeError ( `Unsupported type for encoding: ${ typeof value } ` )
1258+ throw new CodeError ( `Unsupported type for encoding: ${ typeof value } ` )
12591259}
0 commit comments