mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-03 19:36:20 +00:00 
			
		
		
		
	chore: make packages build
This commit is contained in:
		
							parent
							
								
									620bcfe40d
								
							
						
					
					
						commit
						4d66c3c521
					
				@ -19,11 +19,12 @@ describe('useAPIErrorHandler', () => {
 | 
			
		||||
 | 
			
		||||
    const message = result.current.formatAPIError(
 | 
			
		||||
      new FetchError('Error occured', {
 | 
			
		||||
        data: null,
 | 
			
		||||
        error: {
 | 
			
		||||
          name: 'ApplicationError',
 | 
			
		||||
          message: 'Field contains errors',
 | 
			
		||||
          details: {},
 | 
			
		||||
        data: {
 | 
			
		||||
          error: {
 | 
			
		||||
            name: 'ApplicationError',
 | 
			
		||||
            message: 'Field contains errors',
 | 
			
		||||
            details: {},
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
      })
 | 
			
		||||
    );
 | 
			
		||||
@ -36,22 +37,23 @@ describe('useAPIErrorHandler', () => {
 | 
			
		||||
 | 
			
		||||
    const message = result.current.formatAPIError(
 | 
			
		||||
      new FetchError('Fetch Error Occured', {
 | 
			
		||||
        data: null,
 | 
			
		||||
        error: {
 | 
			
		||||
          name: 'ValidationError',
 | 
			
		||||
          message: '',
 | 
			
		||||
          details: {
 | 
			
		||||
            errors: [
 | 
			
		||||
              {
 | 
			
		||||
                path: ['field', '0', 'name'],
 | 
			
		||||
                message: 'Field contains errors',
 | 
			
		||||
              },
 | 
			
		||||
        data: {
 | 
			
		||||
          error: {
 | 
			
		||||
            name: 'ValidationError',
 | 
			
		||||
            message: '',
 | 
			
		||||
            details: {
 | 
			
		||||
              errors: [
 | 
			
		||||
                {
 | 
			
		||||
                  path: ['field', '0', 'name'],
 | 
			
		||||
                  message: 'Field contains errors',
 | 
			
		||||
                },
 | 
			
		||||
 | 
			
		||||
              {
 | 
			
		||||
                path: ['field'],
 | 
			
		||||
                message: 'Field must be unique',
 | 
			
		||||
              },
 | 
			
		||||
            ],
 | 
			
		||||
                {
 | 
			
		||||
                  path: ['field'],
 | 
			
		||||
                  message: 'Field must be unique',
 | 
			
		||||
                },
 | 
			
		||||
              ],
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
      })
 | 
			
		||||
 | 
			
		||||
@ -35,10 +35,9 @@ const fetchBaseQuery = async <TData = unknown, TSend = unknown>({
 | 
			
		||||
     * Default is GET.
 | 
			
		||||
     */
 | 
			
		||||
    const result = await get<TData>(url, config);
 | 
			
		||||
    console.log('baseQuery', result);
 | 
			
		||||
 | 
			
		||||
    return { data: result.data };
 | 
			
		||||
  } catch (error) {
 | 
			
		||||
    console.log('did we arrive here for some reason ?');
 | 
			
		||||
    const err = error as FetchError;
 | 
			
		||||
    /**
 | 
			
		||||
     * Handle error of type FetchError
 | 
			
		||||
@ -51,7 +50,7 @@ const fetchBaseQuery = async <TData = unknown, TSend = unknown>({
 | 
			
		||||
     */
 | 
			
		||||
    return {
 | 
			
		||||
      error: {
 | 
			
		||||
        status: err.response?.error.status,
 | 
			
		||||
        status: err.status,
 | 
			
		||||
        code: err.code,
 | 
			
		||||
        response: {
 | 
			
		||||
          data: err.response?.data,
 | 
			
		||||
 | 
			
		||||
@ -21,7 +21,7 @@ export interface UnknownApiError {
 | 
			
		||||
  status?: number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export type BaseQueryError = ApiError | UnknownApiError;
 | 
			
		||||
export type BaseQueryError = ApiError | UnknownApiError | SerializedError;
 | 
			
		||||
 | 
			
		||||
const fetchBaseQuery =
 | 
			
		||||
  (): BaseQueryFn<string | QueryArguments, unknown, BaseQueryError> =>
 | 
			
		||||
@ -95,8 +95,8 @@ const fetchBaseQuery =
 | 
			
		||||
            error: {
 | 
			
		||||
              name: 'UnknownError',
 | 
			
		||||
              message: 'There was an unknown error response from the API',
 | 
			
		||||
              details: err.response?.data,
 | 
			
		||||
              status: err.response?.error.status,
 | 
			
		||||
              details: err.response,
 | 
			
		||||
              status: err.status,
 | 
			
		||||
            } as UnknownApiError,
 | 
			
		||||
          };
 | 
			
		||||
        }
 | 
			
		||||
@ -114,7 +114,7 @@ const fetchBaseQuery =
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
const isBaseQueryError = (error: BaseQueryError | SerializedError): error is BaseQueryError => {
 | 
			
		||||
const isBaseQueryError = (error: BaseQueryError): error is ApiError | UnknownApiError => {
 | 
			
		||||
  return error.name !== undefined;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -21,7 +21,7 @@ export interface UnknownApiError {
 | 
			
		||||
  status?: number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export type BaseQueryError = ApiError | UnknownApiError;
 | 
			
		||||
export type BaseQueryError = ApiError | UnknownApiError | SerializedError;
 | 
			
		||||
 | 
			
		||||
const fetchBaseQuery =
 | 
			
		||||
  (): BaseQueryFn<string | QueryArguments, unknown, BaseQueryError> =>
 | 
			
		||||
@ -95,8 +95,8 @@ const fetchBaseQuery =
 | 
			
		||||
            error: {
 | 
			
		||||
              name: 'UnknownError',
 | 
			
		||||
              message: 'There was an unknown error response from the API',
 | 
			
		||||
              details: err.response?.data,
 | 
			
		||||
              status: err.response?.error.status,
 | 
			
		||||
              details: err.response,
 | 
			
		||||
              status: err.status,
 | 
			
		||||
            } as UnknownApiError,
 | 
			
		||||
          };
 | 
			
		||||
        }
 | 
			
		||||
@ -114,7 +114,7 @@ const fetchBaseQuery =
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
const isBaseQueryError = (error: BaseQueryError | SerializedError): error is BaseQueryError => {
 | 
			
		||||
const isBaseQueryError = (error: BaseQueryError): error is ApiError | UnknownApiError => {
 | 
			
		||||
  return error.name !== undefined;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user