Skip to content

Commit 903e996

Browse files
committed
chore: refactor generalised model error
1 parent 0034ec1 commit 903e996

File tree

1 file changed

+8
-15
lines changed
  • packages/backend/src/apps/aisay/actions/use-generalised-model

1 file changed

+8
-15
lines changed

packages/backend/src/apps/aisay/actions/use-generalised-model/index.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import appConfig from '@/config/app'
44
import StepError from '@/errors/step'
55

66
import { getToken } from '../../auth/get-token'
7+
import { parseError } from '../../common/error-parser'
78
import { getAttachmentsFromS3, getValidationError } from '../../common/utils'
89

910
import getDataOutMetadata from './get-data-out-metadata'
@@ -111,21 +112,13 @@ const action: IRawAction = {
111112
$.setActionItem({ raw: { ...res.data } })
112113
} catch (err) {
113114
console.error(err)
114-
if (err.response.data.message === `Request Too Long`) {
115-
throw new StepError(
116-
'File too large',
117-
'Please try again with a smaller file.',
118-
$.step.position,
119-
$.app.name,
120-
)
121-
} else {
122-
throw new StepError(
123-
'Failed to call generalised model',
124-
'Please try again.',
125-
$.step.position,
126-
$.app.name,
127-
)
128-
}
115+
const { stepErrorName, stepErrorSolution } = parseError(err)
116+
throw new StepError(
117+
stepErrorName,
118+
stepErrorSolution,
119+
$.step.position,
120+
$.app.name,
121+
)
129122
}
130123
},
131124
} satisfies IRawAction

0 commit comments

Comments
 (0)