Skip to main content

next

PropertyValue
Packagenext
Versions Covered^16.0.0
Contract Version1.0.0
Statusproduction
Last Verified2026-02-25
Maintainercorpus-team

Installation

npm install next

Covered Functions

This contract covers 1 function(s):

GET()

API route handler

Import:

import { GET } from 'next/server';

Postconditions

What happens after calling this function:

🔴 ERROR - route-handler-no-error-handling

Condition: async operation in route handler throws

Throws: Unhandled error returns 500 with stack trace exposed

Required Handling:

Wrap async operations in try-catch and return appropriate error responses

📖 Source


Example: Proper Error Handling

import next from 'next';

async function example() {
try {
const result = await GET(/* args */);
// Handle success
return result;
} catch (error) {
// Handle error according to contract postconditions
console.error('Error:', error);
throw error;
}
}

See Also