Skip to content

Commit

Permalink
bindinds: Add Unsupported error
Browse files Browse the repository at this point in the history
  • Loading branch information
madadam committed Jan 22, 2025
1 parent bbf8674 commit 5bc450c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
22 changes: 14 additions & 8 deletions bindings/dart/lib/exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class OuisyncException implements Exception {
ErrorCode.permissionDenied => PermissionDenied(message, sources),
ErrorCode.serviceAlreadyRunning =>
ServiceAlreadyRunning(message, sources),
ErrorCode.unsupported => Unsupported(message, sources),
ErrorCode.vfsDriverInstallError =>
VFSDriverInstallError(message, sources),
_ => OuisyncException._(code, message, sources),
Expand All @@ -34,31 +35,36 @@ class OuisyncException implements Exception {
String toString() => [message].followedBy(sources).join(' → ');
}

class PermissionDenied extends OuisyncException {
PermissionDenied([String? message, List<String> sources = const []])
: super._(ErrorCode.permissionDenied, message, sources);
class AlreadyExists extends OuisyncException {
AlreadyExists([String? message, List<String> sources = const []])
: super._(ErrorCode.alreadyExists, message, sources);
}

class InvalidData extends OuisyncException {
InvalidData([String? message, List<String> sources = const []])
: super._(ErrorCode.invalidData, message, sources);
}

class AlreadyExists extends OuisyncException {
AlreadyExists([String? message, List<String> sources = const []])
: super._(ErrorCode.alreadyExists, message, sources);
}

class NotFound extends OuisyncException {
NotFound([String? message, List<String> sources = const []])
: super._(ErrorCode.notFound, message, sources);
}

class PermissionDenied extends OuisyncException {
PermissionDenied([String? message, List<String> sources = const []])
: super._(ErrorCode.permissionDenied, message, sources);
}

class ServiceAlreadyRunning extends OuisyncException {
ServiceAlreadyRunning([String? message, List<String> sources = const []])
: super._(ErrorCode.serviceAlreadyRunning, message, sources);
}

class Unsupported extends OuisyncException {
Unsupported([String? message, List<String> sources = const []])
: super._(ErrorCode.unsupported, message, sources);
}

class VFSDriverInstallError extends OuisyncException {
VFSDriverInstallError([String? message, List<String> sources = const []])
: super._(ErrorCode.vfsDriverInstallError, message, sources);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ open class Error internal constructor(
ErrorCode.NOT_FOUND -> NotFound(message, sources)
ErrorCode.STORE_ERROR -> StoreError(message, sources)
ErrorCode.SERVICE_ALREADY_RUNNING -> ServiceAlreadyRunning(message, sources)
ErrorCode.UNSUPPORTED -> Unsupported(message, sources)
else -> Error(code, message, sources)
}
}
Expand All @@ -36,4 +37,6 @@ open class Error internal constructor(

class ServiceAlreadyRunning(message: String? = null, sources: List<String> = emptyList()) :
Error(ErrorCode.SERVICE_ALREADY_RUNNING, message, sources)

class Unsupported(message: String? = null, sources: List<String> = emptyList()) : Error(ErrorCode.UNSUPPORTED, message, sources)
}

0 comments on commit 5bc450c

Please sign in to comment.