Most controllers should not catch validation or auth exceptions only to wrap them again. Let ExceptionMiddleware produce the normal framework response.
CodeBlockdart
class CourseController extends Controller {
Future<Response> store() async {
final data = await req.validate({
'title': 'required|string|min:3',
});
final course = await CreateCourseAction().call(data);
return res.status(201).json({'data': course});
}
}
WebSocket Errors
WebSocket-only contexts do not have an HTTP Response. When ctx.res is null, handle socket errors inside the WebSocket handler and send an event back through ctx.socket.
Use Log.error(...) or Log.critical(...) for server-side failures that need operator attention. Do not log cookies, tokens, OTPs, passwords, authorization headers, or raw request bodies.