Repository: supabase/supabase
File: apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx (TypeScript)

Code before:
                className="space-x-2"
                onClick={(e) => {
                  e.stopPropagation()
                  copyToClipboard(entity.name)
                }}
              >
                <Copy size={12} />
                <span>Copy name</span>
              </DropdownMenuItem>

              {isTableLikeEntityListItem(entity) && (
                <DropdownMenuItem
                  key="copy-schema"
                  className="space-x-2"
                  onClick={async (e) => {
                    e.stopPropagation()
                    const toastId = toast.loading('Getting table schema...')

                    const formattedSchema = getTableDefinition({
                      id: entity.id,
                      projectRef: project?.ref,
                      connectionString: project?.connectionString,
                    }).then((tableDefinition) => {
                      if (!tableDefinition) {
                        toast.error('Failed to get table schema', { id: toastId })
                        return ''
                      }

                      return formatSql(tableDefinition)
                    })

                    try {
                      await copyToClipboard(formattedSchema)
                      toast.success('Table schema copied to clipboard', { id: toastId })
                    } catch (err: any) {
                      toast.error('Failed to copy schema: ' + (err.message || err), {
                        id: toastId,
                      })
                    }
                  }}
                >
                  <Copy size={12} />
                  <span>Copy table schema</span>
                </DropdownMenuItem>
              )}

              {entity.type === ENTITY_TYPE.TABLE && (
                <>
                  <DropdownMenuSeparator />

                  <DropdownMenuItem

Review comment (bug):
```suggestion
                        throw new Error('Failed to get table schema')
```

Code after:
                className="space-x-2"
                onClick={(e) => {
                  e.stopPropagation()
                  copyToClipboard(entity.name)
                }}
              >
                <Copy size={12} />
                <span>Copy name</span>
              </DropdownMenuItem>

              {isTableLikeEntityListItem(entity) && (
                <DropdownMenuItem
                  key="copy-schema"
                  className="space-x-2"
                  onClick={async (e) => {
                    e.stopPropagation()
                    const toastId = toast.loading('Getting table schema...')

                    const formattedSchema = getTableDefinition({
                      id: entity.id,
                      projectRef: project?.ref,
                      connectionString: project?.connectionString,
                    }).then((tableDefinition) => {
                      if (!tableDefinition) {
                        throw new Error('Failed to get table schema')
                      }
                      return formatSql(tableDefinition)
                    })

                    try {
                      await copyToClipboard(formattedSchema)
                      toast.success('Table schema copied to clipboard', { id: toastId })
                    } catch (err: any) {
                      toast.error('Failed to copy schema: ' + (err.message || err), { id: toastId })
                    }
                  }}
                >
                  <Copy size={12} />
                  <span>Copy table schema</span>
                </DropdownMenuItem>
              )}

              {entity.type === ENTITY_TYPE.TABLE && (
                <>
                  <DropdownMenuSeparator />

                  <DropdownMenuItem
                    key="edit-table"
                    className="space-x-2"
                    onClick={(e) => {
                      e.stopPropagation()