PluginProbe
Leadpages / 1.1.2
Leadpages v1.1.2
1.3.0 1.2.1 1.2.2 1.2.3 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0
leadpages / src / utils / api.ts

api.ts in Leadpages 1.1.2, at src/utils/api.ts

17 lines 530 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import type { WPResponseError } from '../types/api';
2
3 export const AUTH_ERROR_CODES = ['leadpages_auth_error', 'no_token'];
4
5 export const getErrorMessage = (e: WPResponseError): string => {
6 const code = e.code;
7 let message = e.message;
8
9 if (code === 'rest_invalid_param' && e.data?.params?.slug) {
10 // simple request where the only thing open to user error is the slug param
11 message = e.data.params.slug;
12 }
13 // add more special handling of error codes here
14
15 return `${message} - ${code}`;
16 };
17