export default function renderErrorLabel()

in packages-demo/console-base-demo-helper-error-prompt/src/util/render-error-label.tsx [52:93]


export default function renderErrorLabel(error: TErrorArg): JSX.Element {
  if (error === null) {
    return <>
      <ScErrorTag type="N" />
      NULL
    </>;
  }
  
  if (error === undefined) {
    return <>
      <ScErrorTag type="U" />
      UNDEFINED
    </>;
  }
  
  if (typeof error === 'string') {
    return <>
      <ScErrorTag type="S" />
      {error}
    </>;
  }
  
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  if (isValidElement<any>(error)) { // TODO TS5 isValidElement 问题 https://github.com/microsoft/TypeScript/issues/53178
    return <>
      <ScErrorTag type="X" />
      JSX
    </>;
  }
  
  if (error instanceof Error) {
    return <>
      <ScErrorTag type="E" />
      {(error as IError).title || error.message}
    </>;
  }
  
  return <>
    <ScErrorTag type="O" />
    {error.title || error.message || error.toString()}
  </>;
}