Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix error types
  • Loading branch information
AbhineetJain committed Aug 1, 2022
commit 94640e43dc9822b1bc77fa75f2fe190eb1294a4a
3 changes: 0 additions & 3 deletions site/src/api/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,3 @@ export const getValidationErrorMessage = (error: Error | ApiError | unknown): st

export const getErrorDetail = (error: Error | ApiError | unknown): string | undefined | null =>
isApiError(error) ? error.response.data.detail : error instanceof Error ? error.stack : null

export const getErrorIfErrorType = (error: Error | unknown): Error | undefined =>
error instanceof Error ? error : undefined
2 changes: 1 addition & 1 deletion site/src/components/Resources/Resources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const Language = {

interface ResourcesProps {
resources?: WorkspaceResource[]
getResourcesError?: Error
getResourcesError?: Error | unknown
workspace: Workspace
canUpdateWorkspace: boolean
}
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/Workspace/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const Workspace: FC<WorkspaceProps> = ({
{!!resources && !!resources.length && (
<Resources
resources={resources}
getResourcesError={workspaceErrors[WorkspaceErrors.GET_RESOURCES_ERROR] as Error}
getResourcesError={workspaceErrors[WorkspaceErrors.GET_RESOURCES_ERROR]}
workspace={workspace}
canUpdateWorkspace={canUpdateWorkspace}
/>
Expand Down
9 changes: 4 additions & 5 deletions site/src/pages/WorkspacePage/WorkspacePage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { makeStyles } from "@material-ui/core/styles"
import { useMachine, useSelector } from "@xstate/react"
import { getErrorIfErrorType } from "api/errors"
import dayjs from "dayjs"
import minMax from "dayjs/plugin/minMax"
import React, { useContext, useEffect } from "react"
Expand Down Expand Up @@ -122,10 +121,10 @@ export const WorkspacePage: React.FC = () => {
builds={builds}
canUpdateWorkspace={canUpdateWorkspace}
workspaceErrors={{
[WorkspaceErrors.GET_RESOURCES_ERROR]: getErrorIfErrorType(getResourcesError),
[WorkspaceErrors.GET_BUILDS_ERROR]: getErrorIfErrorType(getBuildsError),
[WorkspaceErrors.BUILD_ERROR]: getErrorIfErrorType(buildError),
[WorkspaceErrors.CANCELLATION_MESSAGE]: getErrorIfErrorType(cancellationMessage),
[WorkspaceErrors.GET_RESOURCES_ERROR]: getResourcesError,
[WorkspaceErrors.GET_BUILDS_ERROR]: getBuildsError,
[WorkspaceErrors.BUILD_ERROR]: buildError,
[WorkspaceErrors.CANCELLATION_MESSAGE]: cancellationMessage,
}}
/>
<DeleteWorkspaceDialog
Expand Down