| // Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| |
| // Generated code. Do not modify. |
| // |
| // This file is generated by tool/generate_exceptions.dart. |
| // To modify these exceptions, edit lib/src/exceptions.yaml and re-run. |
| |
| import 'package:json_rpc_2/json_rpc_2.dart'; |
| |
| /// JSON-RPC 2.0 error codes that may be returned by worker. |
| enum _ErrorCode { |
| workspaceNotFound(2001), |
| fileNotFound(4001), |
| fileWriteConflict(4002), |
| fileDeletionFailed(4003), |
| languageServerNotFound(5001), |
| compilationFailed(6001), |
| packageConfigNotFound(6020), |
| hotReloadCompilerNotFound(6100), |
| hotReloadRejected(6101), |
| pubCommandFailed(7001), |
| pubUsage(7064), |
| pubData(7065), |
| pubNoInput(7066), |
| pubNoUser(7067), |
| pubNoHost(7068), |
| pubUnavailable(7069), |
| pubSoftware(7070), |
| pubOs(7071), |
| pubOsFile(7072), |
| pubCantCreate(7073), |
| pubIo(7074), |
| pubTempFail(7075), |
| pubProtocol(7076), |
| pubNoPerm(7077), |
| pubConfig(7078), |
| moduleLoaderNotAvailable(8001), |
| flutterLoaderNotAvailable(8002), |
| moduleLoadingFailed(8100), |
| executionFailed(8200), |
| hotRestartFailed(8300), |
| hotReloadFailed(8400); |
| |
| const _ErrorCode(this.code); |
| final int code; |
| } |
| |
| typedef _MakeException = Exception Function(String message, {Object? data}); |
| |
| /// Registry of all DartPadException constructors for use by |
| /// [rethrowAsDartPadException]. |
| final _exceptionRegistry = <_ErrorCode, _MakeException>{ |
| .workspaceNotFound: WorkspaceNotFoundException.new, |
| .fileNotFound: FileNotFoundException.new, |
| .fileWriteConflict: FileWriteConflictException.new, |
| .fileDeletionFailed: FileDeletionFailedException.new, |
| .languageServerNotFound: LanguageServerNotFoundException.new, |
| .compilationFailed: CompilationFailedException.new, |
| .packageConfigNotFound: PackageConfigNotFoundException.new, |
| .hotReloadCompilerNotFound: HotReloadCompilerNotFoundException.new, |
| .hotReloadRejected: HotReloadRejectedException.new, |
| .pubCommandFailed: PubCommandFailedException.new, |
| .pubUsage: PubUsageException.new, |
| .pubData: PubDataException.new, |
| .pubNoInput: PubNoInputException.new, |
| .pubNoUser: PubNoUserException.new, |
| .pubNoHost: PubNoHostException.new, |
| .pubUnavailable: PubUnavailableException.new, |
| .pubSoftware: PubSoftwareException.new, |
| .pubOs: PubOsException.new, |
| .pubOsFile: PubOsFileException.new, |
| .pubCantCreate: PubCantCreateException.new, |
| .pubIo: PubIoException.new, |
| .pubTempFail: PubTempFailException.new, |
| .pubProtocol: PubProtocolException.new, |
| .pubNoPerm: PubNoPermException.new, |
| .pubConfig: PubConfigException.new, |
| .moduleLoaderNotAvailable: ModuleLoaderNotAvailableException.new, |
| .flutterLoaderNotAvailable: FlutterLoaderNotAvailableException.new, |
| .moduleLoadingFailed: ModuleLoadingFailedException.new, |
| .executionFailed: ExecutionFailedException.new, |
| .hotRestartFailed: HotRestartFailedException.new, |
| .hotReloadFailed: HotReloadFailedException.new, |
| }.map((key, value) => MapEntry(key.code, value)); |
| |
| /// Throw a [DartPadException] for [RpcException] depending on error code. |
| Never rethrowAsDartPadException(RpcException e) { |
| final f = _exceptionRegistry[e.code]; |
| if (f != null) { |
| throw f(e.message, data: e.data); |
| } |
| throw e; |
| } |
| |
| final class DartPadException extends RpcException { |
| DartPadException._(String message, _ErrorCode e, {super.data}) |
| : super(e.code, message); |
| |
| @override |
| String toString() => 'DartPadException($code: $message)'; |
| } |
| |
| /// Common base class for exceptions related to your DartPad session. |
| abstract final class SessionException extends DartPadException { |
| SessionException._(super.message, super.e, {super.data}) : super._(); |
| |
| @override |
| String toString() => 'SessionException($code: $message)'; |
| } |
| |
| /// The provided `workspaceId` does not exist. |
| final class WorkspaceNotFoundException extends SessionException { |
| WorkspaceNotFoundException(String message, {super.data}) |
| : super._(message, .workspaceNotFound); |
| |
| @override |
| String toString() => 'WorkspaceNotFoundException($code: $message)'; |
| } |
| |
| /// Common base class for exceptions related to file-system operations. |
| abstract final class FileSystemException extends DartPadException { |
| FileSystemException._(super.message, super.e, {super.data}) : super._(); |
| |
| @override |
| String toString() => 'FileSystemException($code: $message)'; |
| } |
| |
| /// The requested file or directory does not exist. |
| final class FileNotFoundException extends FileSystemException { |
| FileNotFoundException(String message, {super.data}) |
| : super._(message, .fileNotFound); |
| |
| @override |
| String toString() => 'FileNotFoundException($code: $message)'; |
| } |
| |
| /// Could not write file (e.g. parent is a file). |
| final class FileWriteConflictException extends FileSystemException { |
| FileWriteConflictException(String message, {super.data}) |
| : super._(message, .fileWriteConflict); |
| |
| @override |
| String toString() => 'FileWriteConflictException($code: $message)'; |
| } |
| |
| /// Could not delete the requested entity. |
| final class FileDeletionFailedException extends FileSystemException { |
| FileDeletionFailedException(String message, {super.data}) |
| : super._(message, .fileDeletionFailed); |
| |
| @override |
| String toString() => 'FileDeletionFailedException($code: $message)'; |
| } |
| |
| /// Common base class for language server related exceptions. |
| abstract final class LanguageServerException extends DartPadException { |
| LanguageServerException._(super.message, super.e, {super.data}) : super._(); |
| |
| @override |
| String toString() => 'LanguageServerException($code: $message)'; |
| } |
| |
| /// The `languageServerId` does not exist in this workspace. |
| final class LanguageServerNotFoundException extends LanguageServerException { |
| LanguageServerNotFoundException(String message, {super.data}) |
| : super._(message, .languageServerNotFound); |
| |
| @override |
| String toString() => 'LanguageServerNotFoundException($code: $message)'; |
| } |
| |
| /// Common base class for exceptions related to compilation. |
| abstract final class CompilationException extends DartPadException { |
| CompilationException._(super.message, super.e, {super.data}) : super._(); |
| |
| @override |
| String toString() => 'CompilationException($code: $message)'; |
| } |
| |
| /// Failed to compile code, usually due to an issue in the code being |
| /// compiled. |
| final class CompilationFailedException extends CompilationException { |
| CompilationFailedException(String message, {super.data}) |
| : super._(message, .compilationFailed); |
| |
| @override |
| String toString() => 'CompilationFailedException($code: $message)'; |
| } |
| |
| /// Unable to find `.dart_tool/package_config.json` in any parent directory. |
| final class PackageConfigNotFoundException extends CompilationException { |
| PackageConfigNotFoundException(String message, {super.data}) |
| : super._(message, .packageConfigNotFound); |
| |
| @override |
| String toString() => 'PackageConfigNotFoundException($code: $message)'; |
| } |
| |
| /// The `hotReloadCompilerId` does not exist in this workspace. |
| final class HotReloadCompilerNotFoundException extends CompilationException { |
| HotReloadCompilerNotFoundException(String message, {super.data}) |
| : super._(message, .hotReloadCompilerNotFound); |
| |
| @override |
| String toString() => 'HotReloadCompilerNotFoundException($code: $message)'; |
| } |
| |
| /// The hot reload request was rejected by the compiler. |
| final class HotReloadRejectedException extends CompilationException { |
| HotReloadRejectedException(String message, {super.data}) |
| : super._(message, .hotReloadRejected); |
| |
| @override |
| String toString() => 'HotReloadRejectedException($code: $message)'; |
| } |
| |
| /// Common base class for pub related exceptions. |
| abstract final class PubException extends DartPadException { |
| PubException._(super.message, super.e, {super.data}) : super._(); |
| |
| @override |
| String toString() => 'PubException($code: $message)'; |
| } |
| |
| /// The pub command failed to execute successfully. |
| final class PubCommandFailedException extends PubException { |
| PubCommandFailedException(String message, {super.data}) |
| : super._(message, .pubCommandFailed); |
| |
| @override |
| String toString() => 'PubCommandFailedException($code: $message)'; |
| } |
| |
| /// The command was used incorrectly. |
| final class PubUsageException extends PubException { |
| PubUsageException(String message, {super.data}) : super._(message, .pubUsage); |
| |
| @override |
| String toString() => 'PubUsageException($code: $message)'; |
| } |
| |
| /// The input data was incorrect. |
| final class PubDataException extends PubException { |
| PubDataException(String message, {super.data}) : super._(message, .pubData); |
| |
| @override |
| String toString() => 'PubDataException($code: $message)'; |
| } |
| |
| /// An input file did not exist or was unreadable. |
| final class PubNoInputException extends PubException { |
| PubNoInputException(String message, {super.data}) |
| : super._(message, .pubNoInput); |
| |
| @override |
| String toString() => 'PubNoInputException($code: $message)'; |
| } |
| |
| /// The user specified did not exist. |
| final class PubNoUserException extends PubException { |
| PubNoUserException(String message, {super.data}) |
| : super._(message, .pubNoUser); |
| |
| @override |
| String toString() => 'PubNoUserException($code: $message)'; |
| } |
| |
| /// The host specified did not exist. |
| final class PubNoHostException extends PubException { |
| PubNoHostException(String message, {super.data}) |
| : super._(message, .pubNoHost); |
| |
| @override |
| String toString() => 'PubNoHostException($code: $message)'; |
| } |
| |
| /// A service is unavailable. |
| final class PubUnavailableException extends PubException { |
| PubUnavailableException(String message, {super.data}) |
| : super._(message, .pubUnavailable); |
| |
| @override |
| String toString() => 'PubUnavailableException($code: $message)'; |
| } |
| |
| /// An internal software error has been detected. |
| final class PubSoftwareException extends PubException { |
| PubSoftwareException(String message, {super.data}) |
| : super._(message, .pubSoftware); |
| |
| @override |
| String toString() => 'PubSoftwareException($code: $message)'; |
| } |
| |
| /// An operating system error has been detected. |
| final class PubOsException extends PubException { |
| PubOsException(String message, {super.data}) : super._(message, .pubOs); |
| |
| @override |
| String toString() => 'PubOsException($code: $message)'; |
| } |
| |
| /// Some system file did not exist or was unreadable. |
| final class PubOsFileException extends PubException { |
| PubOsFileException(String message, {super.data}) |
| : super._(message, .pubOsFile); |
| |
| @override |
| String toString() => 'PubOsFileException($code: $message)'; |
| } |
| |
| /// A user-specified output file cannot be created. |
| final class PubCantCreateException extends PubException { |
| PubCantCreateException(String message, {super.data}) |
| : super._(message, .pubCantCreate); |
| |
| @override |
| String toString() => 'PubCantCreateException($code: $message)'; |
| } |
| |
| /// An error occurred while doing I/O on some file. |
| final class PubIoException extends PubException { |
| PubIoException(String message, {super.data}) : super._(message, .pubIo); |
| |
| @override |
| String toString() => 'PubIoException($code: $message)'; |
| } |
| |
| /// Temporary failure, indicating something that is not really an error. |
| final class PubTempFailException extends PubException { |
| PubTempFailException(String message, {super.data}) |
| : super._(message, .pubTempFail); |
| |
| @override |
| String toString() => 'PubTempFailException($code: $message)'; |
| } |
| |
| /// The remote system returned something invalid during a protocol exchange. |
| final class PubProtocolException extends PubException { |
| PubProtocolException(String message, {super.data}) |
| : super._(message, .pubProtocol); |
| |
| @override |
| String toString() => 'PubProtocolException($code: $message)'; |
| } |
| |
| /// The user did not have sufficient permissions. |
| final class PubNoPermException extends PubException { |
| PubNoPermException(String message, {super.data}) |
| : super._(message, .pubNoPerm); |
| |
| @override |
| String toString() => 'PubNoPermException($code: $message)'; |
| } |
| |
| /// Something was unconfigured or mis-configured. |
| final class PubConfigException extends PubException { |
| PubConfigException(String message, {super.data}) |
| : super._(message, .pubConfig); |
| |
| @override |
| String toString() => 'PubConfigException($code: $message)'; |
| } |
| |
| /// Common base class for exceptions related to executing of user code in the |
| /// iframe sandbox. |
| abstract final class SandboxException extends DartPadException { |
| SandboxException._(super.message, super.e, {super.data}) : super._(); |
| |
| @override |
| String toString() => 'SandboxException($code: $message)'; |
| } |
| |
| /// The DDC module loader is has not been loaded into the sandbox. |
| final class ModuleLoaderNotAvailableException extends SandboxException { |
| ModuleLoaderNotAvailableException(String message, {super.data}) |
| : super._(message, .moduleLoaderNotAvailable); |
| |
| @override |
| String toString() => 'ModuleLoaderNotAvailableException($code: $message)'; |
| } |
| |
| /// The flutter loader has not been loaded into the sandbox. |
| final class FlutterLoaderNotAvailableException extends SandboxException { |
| FlutterLoaderNotAvailableException(String message, {super.data}) |
| : super._(message, .flutterLoaderNotAvailable); |
| |
| @override |
| String toString() => 'FlutterLoaderNotAvailableException($code: $message)'; |
| } |
| |
| /// Failed to load module into the sandbox. |
| final class ModuleLoadingFailedException extends SandboxException { |
| ModuleLoadingFailedException(String message, {super.data}) |
| : super._(message, .moduleLoadingFailed); |
| |
| @override |
| String toString() => 'ModuleLoadingFailedException($code: $message)'; |
| } |
| |
| /// Error happened when running `main()` from user-code. |
| final class ExecutionFailedException extends SandboxException { |
| ExecutionFailedException(String message, {super.data}) |
| : super._(message, .executionFailed); |
| |
| @override |
| String toString() => 'ExecutionFailedException($code: $message)'; |
| } |
| |
| /// Hot-restart failed. |
| final class HotRestartFailedException extends SandboxException { |
| HotRestartFailedException(String message, {super.data}) |
| : super._(message, .hotRestartFailed); |
| |
| @override |
| String toString() => 'HotRestartFailedException($code: $message)'; |
| } |
| |
| /// Hot-reload failed. |
| final class HotReloadFailedException extends SandboxException { |
| HotReloadFailedException(String message, {super.data}) |
| : super._(message, .hotReloadFailed); |
| |
| @override |
| String toString() => 'HotReloadFailedException($code: $message)'; |
| } |