本文整理汇总了TypeScript中src/utils/api.getErrorMessage函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getErrorMessage函数的具体用法?TypeScript getErrorMessage怎么用?TypeScript getErrorMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getErrorMessage函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
export const importTask = (script: string) => async (
dispatch,
getState: GetStateFunc
): Promise<void> => {
try {
if (_.isEmpty(script)) {
dispatch(notify(taskImportFailed('File is empty')))
return
}
const {
orgs: {org},
} = await getState()
await client.tasks.createByOrgID(org.id, script)
dispatch(getTasks())
dispatch(notify(taskImportSuccess()))
} catch (error) {
console.error(error)
const message = getErrorMessage(error)
dispatch(notify(taskImportFailed(message)))
}
}
示例2: async
export const saveNewScript = (script: string, preamble: string) => async (
dispatch,
getState: GetStateFunc
): Promise<void> => {
try {
const fluxScript = await insertPreambleInScript(script, preamble)
const {
orgs: {org},
} = getState()
await client.tasks.createByOrgID(org.id, fluxScript)
dispatch(setNewScript(''))
dispatch(clearTask())
dispatch(getTasks())
dispatch(goToTasks())
dispatch(notify(taskCreatedSuccess()))
dispatch(checkTaskLimits())
} catch (error) {
console.error(error)
if (isLimitError(error)) {
dispatch(notify(copy.resourceLimitReached('tasks')))
} else {
const message = getErrorMessage(error)
dispatch(notify(taskNotCreated(message)))
}
}
}
示例3: dispatch
export const runTask = (taskID: string) => async dispatch => {
try {
await client.tasks.startRunByTaskID(taskID)
dispatch(notify(taskRunSuccess()))
} catch (error) {
const message = getErrorMessage(error)
dispatch(notify(copy.taskRunFailed(message)))
console.error(error)
}
}
示例4: dispatch
export const cloneTask = (task: Task, _) => async dispatch => {
try {
await client.tasks.clone(task.id)
dispatch(notify(taskCloneSuccess(task.name)))
dispatch(getTasks())
} catch (e) {
console.error(e)
const message = getErrorMessage(e)
dispatch(notify(taskCloneFailed(task.name, message)))
}
}
示例5: async
export const updateBucket = (updatedBucket: Bucket) => async (
dispatch: Dispatch<Action>
) => {
try {
const bucket = await client.buckets.update(updatedBucket.id, updatedBucket)
dispatch(editBucket(bucket))
dispatch(notify(bucketUpdateSuccess(updatedBucket.name)))
} catch (e) {
console.error(e)
const message = getErrorMessage(e)
dispatch(notify(bucketUpdateFailed(message)))
}
}