SOH_2023-Structured errors and error codes for cabal-install
Structured errors and Error codes for Cabal-Install - SoH '23
Contributor : Suganya Raju
Mentor : Gershom Bazerman
The Haskell error Index site https://errors.haskell.org/ describes the error messages produced by the various Haskell related tools.
This project is to refactor the cabal codebase to provide structured errors rather than mere strings, and also assign codes to corresponding cabal errors that can be added to the error index. In the same vein as GHC and other Haskell related tools, the work of this project is moving away from the current way of signaling errors with `die'` to something that allows more structure. The end goal is to have package-specific error data types, where each constructor of such a data type will represent one error corresponding to the error that the module can throw.
Benefits of Structured Errors:
Users have an easier time contributing documentation for how to work around various situations that may arise, so more docs may exist.
Error messages gain a notion of identity that allows them to be rephrased without breaking all docs.
Interactive tools that invoke Cabal and GHC can link to one consistent, predictable location if an error message occurs, and new users don't have to figure out which tool is the source of the error.
New sum types CabalException and CabalInstallException are created.
The die’ function is replaced with a new function dieWithException.
A new datatype “VerboseException a” is created which is polymorphic over “CabalException” and “CabalInstallException”
Each error message is assigned a unique code of the form [Cabal -1234].
List of Exceptions and Error codes :
- NoBenchMarkProgram = 1678
- EnableBenchMark = 1453
- BenchMarkNameDisabled = 2781
- NoBenchMark = 1654
- NoLibraryFound = 2546
- CompilerNotInstalled = 7465
- CantFindIncludeFile = 3876
- UnsupportedTestSuite = 3245
- UnsupportedBenchMark = 9123
- NoIncludeFileFound = 2987
- NoModuleFound = 6421
- RegMultipleInstancePkg = 3421
- SuppressingChecksOnFile = 5436
- NoSupportDirStylePackageDb = 2980
- OnlySupportSpecificPackageDb = 6547
- FailedToParseOutputDescribe = 7218
- DumpFailed = 6736
- FailedToParseOutputDump = 9076
- ListFailed = 5109
- FailedToParseOutputList = 7650
- ProgramNotFound = 4123
- NoSupportForHoogle = 8706
- NoSupportForQuickJumpFlag = 7086
- NoGHCVersionFromHaddock = 5045
- NoGHCVersionFromCompiler = 4098
- HaddockAndGHCVersionDoesntMatch = 1998
- MustHaveSharedLibraries = 6032
- HaddockPackageFlags = 4569
- UnknownCompilerFlavor = 3102
- FailedToDetermineTarget = 5049
- NoMultipleTargets = 6091
- REPLNotSupported = 1098
- NoSupportBuildingTestSuite = 4106
- NoSupportBuildingBenchMark = 5320
- BuildingNotSupportedWithCompiler = 7077
- ProvideHaskellSuiteTool = 7509
- CannotDetermineCompilerVersion = 4519
- PkgDumpFailed = 2291
- FailedToParseOutput = 5500
- CantFindSourceModule = 8870
- VersionMismatchJS = 9001
- VersionMismatchGHCJS = 4001
- GlobalPackageDBLimitation = 5002
- GlobalPackageDBSpecifiedFirst = 3901
- MatchDirFileGlob = 9760
- MatchDirFileGlobErrors = 6661
- ErrorParsingFileDoesntExist = 1234
- FailedParsing = 6565
- NotFoundMsg = 8011
- UnrecognisedBuildTarget = 3410
- ReportBuildTargetProblems = 5504
- UnknownBuildTarget = 4444
- AmbiguousBuildTarget = 7865
- CheckBuildTargets = 4733
- VersionMismatchGHC = 4000
- CheckPackageDbStackPost76 = 3000
- CheckPackageDbStackPre76 = 5640
- GlobalPackageDbSpecifiedFirst = 2345
- CantInstallForeignLib = 8221
- NoSupportForPreProcessingTest = 3008
- NoSupportForPreProcessingBenchmark = 6990
- CantFindSourceForPreProcessFile = 7554
- NoSupportPreProcessingTestExtras = 7886
- NoSupportPreProcessingBenchmarkExtras = 9999
- UnlitException = 5454
- RunProgramInvocationException = 8012
- GetProgramInvocationException = 7300
- GetProgramInvocationLBSException = 6578
- CheckSemaphoreSupport = 2002
- NoLibraryForPackage = 8004
- SanityCheckHookedBuildInfo = 6007
- ConfigureScriptNotFound = 4567
- NoValidComponent = 5680
- ConfigureEitherSingleOrAll = 2001
- ConfigCIDValidForPreComponent = 7006
- SanityCheckForEnableComponents = 5004
- SanityCheckForDynamicStaticLinking = 4007
- UnsupportedLanguages = 8074
- UnsupportedLanguageExtension = 5656
- CantFindForeignLibraries = 4574
- ExpectedAbsoluteDirectory = 6662
- FlagsNotSpecified = 9080
- EncounteredMissingDependency = 8010
- CompilerDoesn'tSupportThinning = 4003
- CompilerDoesn'tSupportReexports = 3456
- CompilerDoesn'tSupportBackpack = 5446
- LibraryWithinSamePackage = 7007
- ReportFailedDependencies = 4321
- NoPackageDatabaseSpecified = 2300
- HowToFindInstalledPackages = 3003
- PkgConfigNotFound = 7123
- BadVersion = 7600
- UnknownCompilerException = 3022
- NoWorkingGcc = 1088
- NoOSSupport = 3339
- NoCompilerSupport = 2290
- InstallDirsNotPrefixRelative = 6000
- ExplainErrors = 4345
- CheckPackageProblems = 5559
- LibDirDepsPrefixNotRelative = 6667
- CombinedConstraints = 5000
- CantParseGHCOutput = 1980
- IncompatibleWithCabal = 8123
- Couldn'tFindTestProgram = 5678
- TestCoverageSupport = 7890
- Couldn'tFindTestProgLibV09 = 9012
- TestCoverageSupportLibV09 = 1076
- RawSystemStdout = 3098
- FindFileCwd = 4765
- FindFileEx = 2115
- FindModuleFileEx = 6663
- MultipleFilesWithExtension = 3333
- NoDesc = 7654
- MultiDesc = 5554
- RelocRegistrationInfo = 4343
- CreatePackageDB = 6787
- WithHcPkg = 9876
- RegisMultiplePkgNotSupported = 7632
- RegisteringNotImplemented = 5411
- NoTestSuitesEnabled = 9061
- TestNameDisabled = 8210
- NoSuchTest = 8000
- ConfigureProgram = 5490
- RequireProgram = 6666
- NoProgramFound = 7620
- BadVersionDb = 8038
- UnknownVersionDb = 1008
- UnpackGet = 7013
- NotTarballDir = 7012
- DirectoryAlreadyExists = 7014
- FileExists = 7015
- FileAlreadyExists = 7016
- DirectoryExists = 7017
- SplitRunArgs = 7018
- CouldNotFindExecutable = 7019
- FoundMultipleMatchingExes = 7020
- NoRemoteRepositories = 7021
- NotATarDotGzFile = 7022
- ExpectedMatchingFileName = 7023
- NoTargetProvided = 7024
- OneTargetRequired = 7025
- ThisIsABug = 7026
- NoOrMultipleTargetsGiven = 7027
- NoTargetFound = 7028
- MultipleTargetsFound = 7029
- UnexpectedNamedPkgSpecifiers = 7030
- UnexpectedSourcePkgSpecifiers = 7031
- UnableToPerformInplaceUpdate = 7032
- EmptyValuePagerEnvVariable = 7033
- FileDoesntExist = 7034
- ParseError = 7035
- CabalFileNotFound = 7036
- FindOpenProgramLocationErr = 7037
- PkgConfParseFailed = 7038
- ErrorPackingSdist = 7039
- SdistException = 7040
- SpecifyAnExecutable = 7041
- TestCommandDoesn'tSupport = 7042
- ReportTargetProblems = 7043
- ListBinTargetException = 7044
- ResolveWithoutDependency = 7045
- CannotReadCabalFile = 7046
- ErrorUpdatingIndex = 7047
- InternalError = 7048
- ReadIndexCache = 7049
- ConfigStateFileException = 7050
- UploadAction = 7051
- UploadActionDocumentation = 7052
- UploadActionOnlyArchives = 7053
- FileNotFound = 7054
- CheckAction = 7055
- ReportAction = 7056
- InitAction = 7057
- UserConfigAction = 7058
- SpecifySubcommand = 7059
- UnknownUserConfigSubcommand = 7060
- ManpageAction = 7061
- UnrecognizedResponse = 7062
- CheckTarget = 7063
- FetchPackage = 7064
- PlanPackages = 7065
- NoSupportForRunCommand = 7066
- RunPhaseReached = 7067
- UnknownExecutable = 7068
- MultipleMatchingExecutables = 7069
- CmdRunReportTargetProblems = 7070
- CleanAction = 7071
- ReportCannotPruneDependencies = 7072
- ReplCommandDoesn'tSupport = 7073
- ReplTakesNoArguments = 7074
- ReplTakesSingleArgument = 7075
- RenderReplTargetProblem = 7076
- GetPkgList = 7078
- GatherPkgInfo = 7079
- UnableToParseRepo = 7080
- NullUnknownrepos = 7081
- UpdateSetupScript = 7082
- InstalledCabalVersion = 7083
- FailNoConfigFile = 7084
- ParseFailedErr = 7085
- ParseExtraLinesFailedErr = 7087
- ParseExtraLinesOkError = 7088
- FetchPackageErr = 7089
- ReportParseResult = 7090
- ReportSourceRepoProblems = 7091
- BenchActionException = 7092
- RenderBenchTargetProblem = 7093
- ReportUserTargetProblems = 7094
- ReportUserTargerNonexistantFile = 7095
- ReportUserTargetUnexpectedFile = 7096
- ReportUserTargetUnexpectedUriScheme = 7097
- ReportUserTargetUnrecognisedUri = 7098
- ReadTarballPackageTarget = 7099
- ReportPackageTargetProblems = 7100
- PackageNameAmbiguousErr = 7101
- ExtractTarballPackageErr = 7102
- OutdatedAction = 7103
- FreezeFileExistsErr = 7104
- FinalizePDFailed = 7105
- ProjectTargetSelector = 7106
- PhaseRunSolverErr = 7107
- HaddockCommandDoesn'tSupport = 7108
- CannotParseURIFragment = 7109
- MakeDownload = 7110
- FailedToDownloadURI = 7111
- RemoteRepoCheckHttps = 7112
- TransportCheckHttps = 7113
- NoPostYet = 7114
- WGetServerError = 7115
- Couldn'tEstablishHttpConnection = 7116
- StatusParseFail = 7117
- TryUpgradeToHttps = 7118
- UnknownHttpTransportSpecified = 7119
- CmdHaddockReportTargetProblems = 7120
- FailedExtractingScriptBlock = 7121
- FreezeAction = 7122
- TryFindPackageDescErr = 7124
- DieIfNotHaddockFailureException = 7125
- ConfigureInstallInternalError = 7126
- CmdErrorMessages = 7127
- ReportTargetSelectorProblems = 7128
- UnrecognisedTarget = 7129
- NoSuchTargetSelectorErr = 7131
- TargetSelectorAmbiguousErr = 7132
- TargetSelectorNoCurrentPackageErr = 7133
- TargetSelectorNoTargetsInCwdTrue = 7134
- TargetSelectorNoTargetsInCwdFalse = 7135
- TargetSelectorNoTargetsInProjectErr = 7136
- TargetSelectorNoScriptErr = 7137
- MatchingInternalErrorErr = 7130
- ReportPlanningFailure = 7138
- Can'tDownloadPackagesOffline = 7139
- SomePackagesFailedToInstall = 7140
- PackageDotCabalFileNotFound = 7141
- PkgConfParsedFailed = 7142
- BrokenException = 7143
- WithoutProject = 7144
- PackagesAlreadyExistInEnvfile = 7145
- ConfigTests = 7146
- ConfigBenchmarks = 7147
- UnknownPackage = 7148
- InstallUnitExes = 7149
- SelectComponentTargetError = 7150
- SdistActionException = 7151
- Can'tWriteMultipleTarballs = 7152
- ImpossibleHappened = 7153
- CannotConvertTarballPackage = 7154
- Win32SelfUpgradeNotNeeded = 7155
- FreezeException = 7156
- PkgSpecifierException = 7157
- CorruptedIndexCache = 7158
Future Work:
- One instance of die' in Cabal/src/Distribution/Program/Run.hs is not replaced with the new dieWithException function. This change started giving a windows specific error and couldn't pass the CI. Future work on this will be to replace the die' function and identify the CI-Windows error.
- The error codes that we have generated as part of this project will have to be added to the Haskell error Index.
Challenges and Learnings:
The major challenge that I faced initially was understanding the logic within the code that was written by other contributors. Since this was my first time contributing to an open source project, it took me some time to get familiar with the overall process.
I would say that Summer of Haskell has introduced me to the world of open source and given me the joy of being a part of something huge. I have evolved to become a better programmer in the last 22 weeks, and look forward to continue contributing.
Comments
Post a Comment