PluginProbe
Code Snippets / 4.0.0-beta.2
Code Snippets v4.0.0-beta.2
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
← All changes | js/hooks/useSubmitSnippet.tsx +3 -2 3.10.0 → 4.0.0-beta.2 View file →
@@ -1,7 +1,8 @@
1 1 import { __ } from '@wordpress/i18n'
2 2 import { isAxiosError } from 'axios'
3 3 import React, { useCallback } from 'react'
4 +import { describeRequestError } from '../utils/errors'
4 5 import { useSnippetForm } from '../components/EditMenu/SnippetForm/WithSnippetFormContext'
5 6 import { createSnippetObject, isCondition } from '../utils/snippets/snippets'
6 7 import { buildUrl } from '../utils/urls'
7 8 import { useSnippetsAPI } from './useSnippetsAPI'
@@ -112,10 +113,10 @@
112 113 ? api.create(request)
113 114 : api.update({ ...request, id }))
114 115
115 116 return response.id ? createSnippetObject(response) : undefined
116 - } catch (error) {
117 - return isAxiosError(error) ? error.message : undefined
117 + } catch (error: unknown) {
118 + return isAxiosError(error) ? describeRequestError(error) : undefined
118 119 } finally {
119 120 setIsWorking(false)
120 121 }
121 122 })()