Skip to content

Commit fa32c77

Browse files
committed
refactor: use more appropriate error classes
1 parent 3a34b50 commit fa32c77

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import type { uint64 } from '@algorandfoundation/algorand-typescript'
22
import type { AbiMetadata } from '../abi-metadata'
3-
import { CodeError } from '../errors'
3+
import { AssertError } from '../errors'
44
import { ApplicationTransaction } from '../impl/transactions'
55
import { lazyContext } from './internal-context'
66

77
export const checkRoutingConditions = (appId: uint64, metadata: AbiMetadata) => {
88
const appData = lazyContext.getApplicationData(appId)
99
const isCreating = appData.isCreating
1010
if (isCreating && metadata.onCreate === 'disallow') {
11-
throw new CodeError('method can not be called while creating')
11+
throw new AssertError('method can not be called while creating')
1212
}
1313
if (!isCreating && metadata.onCreate === 'require') {
14-
throw new CodeError('method can only be called while creating')
14+
throw new AssertError('method can only be called while creating')
1515
}
1616
const txn = lazyContext.activeGroup.activeTransaction
1717
if (txn instanceof ApplicationTransaction && metadata.allowActions && !metadata.allowActions.includes(txn.onCompletion)) {
18-
throw new CodeError(`method can only be called with one of the following on_completion values: ${metadata.allowActions.join(', ')}`)
18+
throw new AssertError(`method can only be called with one of the following on_completion values: ${metadata.allowActions.join(', ')}`)
1919
}
2020
}

src/impl/box.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { bytes, op, uint64 } from '@algorandfoundation/algorand-typescript'
22
import { MAX_BOX_SIZE } from '../constants'
33
import { lazyContext } from '../context-helpers/internal-context'
44
import { toBytes } from '../encoders'
5-
import { InternalError } from '../errors'
5+
import { AvmError, InternalError } from '../errors'
66
import { asBytes, asBytesCls, asNumber, asUint8Array, conactUint8Arrays } from '../util'
77
import type { StubBytesCompat, StubUint64Compat } from './primitives'
88

@@ -11,7 +11,7 @@ export const Box: typeof op.Box = {
1111
const name = asBytes(a)
1212
const size = asNumber(b)
1313
if (name.length === 0 || size > MAX_BOX_SIZE) {
14-
throw new InternalError('Invalid box name or size')
14+
throw new AvmError('Invalid box name or size')
1515
}
1616
const app = lazyContext.activeApplication
1717
if (lazyContext.ledger.boxExists(app, name)) {

0 commit comments

Comments
 (0)