MCPcopy
hub / github.com/amplication/amplication / formatError

Function formatError

packages/amplication-client/src/util/error.ts:4–23  ·  view source on GitHub ↗
(
  error: Error | undefined | null
)

Source from the content-addressed store, hash-verified

2import { AxiosError } from "axios";
3
4export function formatError(
5 error: Error | undefined | null
6): string | undefined {
7 if (error === undefined || error === null) {
8 return undefined;
9 }
10 if ((error as ApolloError).graphQLErrors) {
11 // show the first error
12 /**@todo: return multiple errors */
13 const [gqlError] = (error as ApolloError).graphQLErrors;
14 if (gqlError && gqlError.message) {
15 return gqlError.message;
16 }
17 }
18
19 if (error instanceof AxiosError) {
20 return (error as AxiosError).message;
21 }
22 return String(error);
23}

Callers 15

PrivatePluginFunction · 0.90
DeletePrivatePluginFunction · 0.90
NewPrivatePluginVersionFunction · 0.90
PrivatePluginVersionFunction · 0.90
PrivatePluginDevVersionFunction · 0.90
OwnerSelectorFunction · 0.90
NewEntityFunction · 0.90
EntityListFunction · 0.90
EntityFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected