Skip to content

Commit

Permalink
chore: change kind to name
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasheartman committed Apr 25, 2023
1 parent 9ae66c5 commit 6a16be1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/lib/error/api-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ const AllUnleashApiErrorTypes = [
...UnleashApiErrorTypesWithExtraData,
] as const;

type UnleashApiErrorType = typeof AllUnleashApiErrorTypes[number];
type UnleashApiErrorName = typeof AllUnleashApiErrorTypes[number];

const statusCode = (errorKind: UnleashApiErrorType): number => {
switch (errorKind) {
const statusCode = (errorName: UnleashApiErrorName): number => {
switch (errorName) {
case 'ContentTypeError':
return 415;
case 'ValidationError':
Expand Down Expand Up @@ -107,7 +107,7 @@ type UnleashErrorData =
} & (
| {
name: Exclude<
UnleashApiErrorType,
UnleashApiErrorName,
| 'NoAccessError'
| 'AuthenticationRequired'
| 'ValidationError'
Expand Down Expand Up @@ -140,7 +140,7 @@ type UnleashErrorData =
export class UnleashError extends Error {
id: string;

name: UnleashApiErrorType;
name: UnleashApiErrorName;

documentationLink: string | null;

Expand Down Expand Up @@ -214,8 +214,8 @@ export const apiErrorSchema = {
} as const;

export const fromLegacyError = (e: Error): UnleashError => {
const name = AllUnleashApiErrorTypes.includes(e.name as UnleashApiErrorType)
? (e.name as UnleashApiErrorType)
const name = AllUnleashApiErrorTypes.includes(e.name as UnleashApiErrorName)
? (e.name as UnleashApiErrorName)
: 'UnknownError';

if (name === 'NoAccessError') {
Expand Down

0 comments on commit 6a16be1

Please sign in to comment.