DIYgod/RSSHub · error · Error

Unhandle type: ${c.type}

Error message

Unhandle type: ${c.type}

What it means

Famitsu article bodies are arrays of typed components. The switch handles TEXT, YOUTUBE, several BUTTON_* variants, and LINK/LINK_TAB; every other `c.type` hits `default` and throws a generic Error (the message reads 'Unhandle type' — a typo). This is a parser-completeness gap.

Source

Thrown at lib/routes/famitsu/category.tsx:94

        case 'ITEMIZATION':
        case 'ITEMIZATION_NUM':
        case 'NOLINK':
        case 'PBOX':
        case 'STRING':
        case 'TWITTER':
        case 'YOUTUBE':
            return `<div><span>${c.content}</span></div>`;
        case 'BUTTON':
        case 'BUTTON_ANDROID':
        case 'BUTTON_EC':
        case 'BUTTON_IOS':
        case 'BUTTON_QUESTION':
        case 'BUTTON_TAB':
        case 'LINK':
        case 'LINK_TAB':
            return `<a href="${c.url}">${c.content}</a><br>`;
        default:
            throw new Error(`Unhandle type: ${c.type}`);
    }
}

async function handler(ctx) {
    const { category = 'new-article' } = ctx.req.param();
    const url = `${baseUrl}/category/${category}/page/1`;

    const buildId = await getBuildId();

    const data = await ofetch(`https://www.famitsu.com/_next/data/${buildId}/category/${category}/page/1.json`, {
        query: {
            categoryCode: category,
            pageNumber: 1,
        },
    });

    const list = (data.pageProps.categoryArticleDataForPc as CategoryArticle[])
        .filter((item) => !item.advertiserName)

View on GitHub (pinned to bed535e087)

Solutions

  1. Inspect the component `type` from the error message and add a rendering case.
  2. Return an empty string in the `default` arm for graceful degradation.
  3. Optionally correct the message typo ('Unhandle' -> 'Unhandled') when patching.

Example fix

// before
//   default:
//       throw new Error(`Unhandle type: ${c.type}`);
// after
//   default:
//       return '';
Defensive patterns

Strategy: fallback

Validate before calling

const HANDLED = new Set(['TEXT', 'YOUTUBE', 'BUTTON', 'BUTTON_ANDROID', 'BUTTON_EC', 'BUTTON_IOS', 'BUTTON_QUESTION', 'BUTTON_TAB', 'LINK', 'LINK_TAB']);
function isHandledComponent(c: { type: string }): boolean {
  return HANDLED.has(c.type);
}

Type guard

function isHandledComponent(c: { type: string }): boolean {
  return HANDLED.has(c.type);
}

Try / catch

try {
  return renderComponent(c);
} catch {
  return '';
}

Prevention

When it happens

Trigger: Famitsu introduces a component type the switch doesn't cover (e.g. IMAGE, GALLERY, VIDEO, EMBED, CAROUSEL).

Common situations: A site relaunch adds new block types; only articles using the new blocks fail.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/9c9e69d72d05272f. Report an issue: GitHub.