bharat_erp/lib/core/errors/exceptions.dart
SurendarSuri30 8f852ac4f6 Initial commit: Bharat ERP Flutter application.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-19 15:04:06 +05:30

73 lines
1.6 KiB
Dart

class ServerException implements Exception {
const ServerException({
required this.message,
this.code,
this.statusCode,
});
final String message;
final String? code;
final int? statusCode;
@override
String toString() => 'ServerException: $message (code: $code, status: $statusCode)';
}
class NetworkException implements Exception {
const NetworkException([this.message = 'No internet connection']);
final String message;
@override
String toString() => 'NetworkException: $message';
}
class UnauthorizedException implements Exception {
const UnauthorizedException([this.message = 'Unauthorized']);
final String message;
@override
String toString() => 'UnauthorizedException: $message';
}
class ValidationException implements Exception {
const ValidationException({
required this.message,
this.errors,
});
final String message;
final Map<String, List<String>>? errors;
@override
String toString() => 'ValidationException: $message';
}
class ForbiddenException implements Exception {
const ForbiddenException([this.message = 'Access denied']);
final String message;
@override
String toString() => 'ForbiddenException: $message';
}
class ConflictException implements Exception {
const ConflictException([this.message = 'Conflict']);
final String message;
@override
String toString() => 'ConflictException: $message';
}
class CacheException implements Exception {
const CacheException([this.message = 'Cache error']);
final String message;
@override
String toString() => 'CacheException: $message';
}