Backed out changeset 4191b252db9b (bug 1886734) for causing build bustages @netwerk...
[gecko.git] / js / loader / ResolveResult.h
blobe7b415198c82c32986b88a619abf2adc36d5baed
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef js_loader_ResolveResult_h
8 #define js_loader_ResolveResult_h
10 #include "mozilla/ResultVariant.h"
11 #include "mozilla/NotNull.h"
12 #include "nsIURI.h"
14 namespace JS::loader {
16 enum class ResolveError : uint8_t {
17 Failure,
18 FailureMayBeBare,
19 BlockedByNullEntry,
20 BlockedByAfterPrefix,
21 BlockedByBacktrackingPrefix,
22 InvalidBareSpecifier,
23 Length
26 struct ResolveErrorInfo {
27 static const char* GetString(ResolveError aError) {
28 switch (aError) {
29 case ResolveError::Failure:
30 return "ModuleResolveFailureNoWarn";
31 case ResolveError::FailureMayBeBare:
32 return "ModuleResolveFailureWarnRelative";
33 case ResolveError::BlockedByNullEntry:
34 return "ImportMapResolutionBlockedByNullEntry";
35 case ResolveError::BlockedByAfterPrefix:
36 return "ImportMapResolutionBlockedByAfterPrefix";
37 case ResolveError::BlockedByBacktrackingPrefix:
38 return "ImportMapResolutionBlockedByBacktrackingPrefix";
39 case ResolveError::InvalidBareSpecifier:
40 return "ImportMapResolveInvalidBareSpecifierWarnRelative";
41 default:
42 MOZ_CRASH("Unexpected ResolveError value");
47 /**
48 * ResolveResult is used to store the result of 'resolving a module specifier',
49 * which could be an URI on success or a ResolveError on failure.
51 using ResolveResult =
52 mozilla::Result<mozilla::NotNull<nsCOMPtr<nsIURI>>, ResolveError>;
53 } // namespace JS::loader
55 #endif // js_loader_ResolveResult_h