| // 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), | |
| pubCommandFailed(6001), | |
| pubUsage(6064), | |
| pubData(6065), | |
| pubNoInput(6066), | |
| pubNoUser(6067), | |
| pubNoHost(6068), | |
| pubUnavailable(6069), | |
| pubSoftware(6070), | |
| pubOs(6071), | |
| pubOsFile(6072), | |
| pubCantCreate(6073), | |
| pubIo(6074), | |
| pubTempFail(6075), | |
| pubProtocol(6076), | |
| pubNoPerm(6077), | |
| pubConfig(6078), | |
| sandboxNotFound(7001), | |
| invalidSandboxState(7002), | |
| compilationFailed(7101), | |
| packageConfigNotFound(7102), | |
| hotReloadRejected(7103), | |
| moduleLoadingFailed(7104), | |
| executionFailed(7201); | |
| 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, | |
| .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, | |
| .sandboxNotFound: SandboxNotFoundException.new, | |
| .invalidSandboxState: InvalidSandboxStateException.new, | |
| .compilationFailed: CompilationFailedException.new, | |
| .packageConfigNotFound: PackageConfigNotFoundException.new, | |
| .hotReloadRejected: HotReloadRejectedException.new, | |
| .moduleLoadingFailed: ModuleLoadingFailedException.new, | |
| .executionFailed: ExecutionFailedException.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 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)'; | |
| } | |
| /// Sandbox with the given `sandboxId` was not found. | |
| final class SandboxNotFoundException extends SandboxException { | |
| SandboxNotFoundException(String message, {super.data}) | |
| : super._(message, .sandboxNotFound); | |
| @override | |
| String toString() => 'SandboxNotFoundException($code: $message)'; | |
| } | |
| /// Sandbox methods have not been called in correct order. | |
| final class InvalidSandboxStateException extends SandboxException { | |
| InvalidSandboxStateException(String message, {super.data}) | |
| : super._(message, .invalidSandboxState); | |
| @override | |
| String toString() => 'InvalidSandboxStateException($code: $message)'; | |
| } | |
| /// Failed to compile code, usually due to an issue in the code being | |
| /// compiled. | |
| final class CompilationFailedException extends SandboxException { | |
| 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 SandboxException { | |
| PackageConfigNotFoundException(String message, {super.data}) | |
| : super._(message, .packageConfigNotFound); | |
| @override | |
| String toString() => 'PackageConfigNotFoundException($code: $message)'; | |
| } | |
| /// The hot reload request was rejected by the compiler. | |
| final class HotReloadRejectedException extends SandboxException { | |
| HotReloadRejectedException(String message, {super.data}) | |
| : super._(message, .hotReloadRejected); | |
| @override | |
| String toString() => 'HotReloadRejectedException($code: $message)'; | |
| } | |
| /// A compiled module failed to load in the sandboxed iframe. | |
| 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)'; | |
| } |