DIYgod/RSSHub · warning · Error

Category "${category}" not found

Error message

Category "${category}" not found

What it means

The The Wire Hindi category route keeps a static categories array and finds the requested category by exact value match. If categories.find returns undefined (the :category param matches no entry), it throws a generic Error. This is purely a client-side validation against a hardcoded list before any API call.

Source

Thrown at lib/routes/thewirehindi/category.ts:63

        supportScihub: false,
    },
    radar: [
        {
            source: ['thewirehindi.com/category/*'],
        },
    ],
    name: 'Category',
    maintainers: ['Rjnishant530'],
    handler,
    url: 'thewirehindi.com/',
};

async function handler(ctx) {
    const { category } = ctx.req.param();
    const categoryData = categories.find((cat) => cat.value === category);

    if (!categoryData) {
        throw new Error(`Category "${category}" not found`);
    }

    const apiUrl = `https://thewirehindi.com/wp-json/wp/v2/posts?categories=${categoryData.id}&_embed`;
    const { data } = await got(apiUrl);

    const items = data.map((v) => mapPostToItem(v));

    return {
        title: `The Wire Hindi - ${categoryData.label}`,
        link: `https://thewirehindi.com/category/${category}/`,
        item: items,
        description: `Latest news from The Wire Hindi - ${categoryData.label} category`,
        logo: 'https://thewirehindi.com/wp-content/uploads/2023/05/cropped-The-wire-32x32.jpeg',
        language: 'hi',
    } as Data;
}

View on GitHub (pinned to bed535e087)

Solutions

  1. Use a category value present in the route's categories array (open the route file to see valid values).
  2. If the site has a new category, add it to the categories array with its WordPress id and label.
  3. Throw InvalidParameterError instead of a generic Error for consistency with other routes.

Example fix

// before
const categoryData = categories.find((cat) => cat.value === category);
if (!categoryData) {
    throw new Error(`Category "${category}" not found`);
}

// after: case-insensitive match and a clearer error
const categoryData = categories.find((cat) => cat.value.toLowerCase() === category.toLowerCase());
if (!categoryData) {
    throw new InvalidParameterError(`Category "${category}" not found. Supported: ${categories.map((c) => c.value).join(', ')}`);
}
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED = new Set(categories.map((c) => c.value.toLowerCase()));
function isSupportedCategory(c: string): boolean {
    return SUPPORTED.has(c.toLowerCase());
}
// reject unsupported categories at the route boundary

Type guard

function isTheWireHindiCategory(c: string): boolean {
    return categories.some((cat) => cat.value.toLowerCase() === c.toLowerCase());
}

Try / catch

try {
    return await handler(ctx);
} catch (e) {
    if (e instanceof Error && /Category .* not found/.test(e.message)) {
        return notFound(`Supported: ${categories.map((c) => c.value).join(', ')}`);
    }
    throw e;
}

Prevention

When it happens

Trigger: Requesting /thewirehindi/<category> with a value that does not equal any cat.value in the local categories array (typo, removed category, or a category that exists on the site but was not added to the list).

Common situations: User mistypes the category; a new site category was never added to the route's array; case mismatch between the URL and the stored value.

Related errors


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