docs / Compiler

Errors & Diagnostics

VeskError, HttpError, TimeoutError and NotFoundError, plus error handling in components and server code.

Vesk provides structured error types for common failure scenarios.

VeskError

compiler
									
										import { VeskError } from '@vesk/compiler';

throw new VeskError({
  code: 'V0412',
  message: 'Reactive read outside a tracked scope',
  file: 'app/page.vsk',
  line: 15,
  column: 3,
  help: 'Move the reactive read inside an effect() or component body.',
});
									
								
  • Every VeskError carries a stable V-code, message, file, line, column and a suggested help line.
  • `codeFrame()` returns a formatted code frame with the caret pointing at the problem.

Runtime error types

Type Properties When thrown
HttpError status, statusText Non-2xx HTTP response
TimeoutError timeout (ms) Request exceeded its timeout
NotFoundError — notFound(); renders not-found.vsk

In components

app/components/SafePage.vsk
										
											component SafePage() {
  try {
    <RiskyComponent />
  } catch (err) {
    <p>Error: {err.message}</p>
  }
}
										
									

In server code

app/api/items/route.ts
									
										export async function GET(request: Request) {
  try {
    const data = await fetchExternalData();
    return Response.json(data);
  } catch (err) {
    if (err instanceof TimeoutError) {
      return Response.json(
        { error: `Request timed out after ${err.timeout}ms` },
        { status: 504 }
      );
    }
    throw err;
  }
}