Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
61 lines
2.2 KiB
Dart
61 lines
2.2 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:cutdex_sdk/editor.dart';
|
|
import 'package:cutdex_sdk/project.dart';
|
|
|
|
import '../errors/app_failure.dart';
|
|
|
|
/// Adapts SDK errors by code. Unknown errors retain their complete diagnostics.
|
|
AppFailure appFailureFromError(Object error) {
|
|
if (error is AppException) return error.failure;
|
|
if (error is AppFailure) return error;
|
|
final AppErrorCode code;
|
|
switch (error) {
|
|
case CommandRejected(:final code):
|
|
final mapped = switch (code) {
|
|
'missingMedia' => AppErrorCode.mediaNoLongerExists,
|
|
'staleVersion' ||
|
|
'invalidSelection' ||
|
|
'missingClip' => AppErrorCode.timelineChanged,
|
|
'missingTimeline' ||
|
|
'timelineNotOpen' => AppErrorCode.openTimelineFailed,
|
|
'projectNotOpen' => AppErrorCode.openMatchingProject,
|
|
'missingProject' => AppErrorCode.openProjectFirst,
|
|
'projectIdMismatch' => AppErrorCode.projectMismatch,
|
|
'unsupported' ||
|
|
'unavailable' ||
|
|
'busy' ||
|
|
'cancelled' ||
|
|
'workspaceBusy' ||
|
|
'projectCreationFailed' ||
|
|
'invalidArguments' => AppErrorCode.operationFailed,
|
|
_ => AppErrorCode.diagnostic,
|
|
};
|
|
return AppFailure(mapped, diagnostic: error.toString());
|
|
case ProjectFileException(:final code):
|
|
final mapped = switch (code) {
|
|
ProjectFileError.notFound => AppErrorCode.projectMissingDirectory,
|
|
ProjectFileError.closed => AppErrorCode.projectSessionClosed,
|
|
ProjectFileError.conflict => AppErrorCode.projectMismatch,
|
|
_ => AppErrorCode.projectAccessFailed,
|
|
};
|
|
return AppFailure(mapped, diagnostic: error.toString());
|
|
default:
|
|
code = AppErrorCode.diagnostic;
|
|
}
|
|
return AppFailure(code, diagnostic: error.toString());
|
|
}
|
|
|
|
/// Project operations provide context for otherwise unclassified I/O failures.
|
|
AppFailure projectFailureFromError(Object error) => switch (error) {
|
|
FileSystemException() => AppFailure(
|
|
AppErrorCode.projectAccessFailed,
|
|
diagnostic: error.toString(),
|
|
),
|
|
AppException() ||
|
|
CommandRejected() ||
|
|
ProjectFileException() ||
|
|
StateError() => appFailureFromError(error),
|
|
_ => AppFailure(AppErrorCode.operationFailed, diagnostic: error.toString()),
|
|
};
|