-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(extension/#2676): Part 1 - Fix error message with missing extensi…
…on dependency (#3007) __Issue:__ When an extension has a required dependency that is not installed, Onivim would fail to activate the extension silently. __Defect:__ Onivim was not properly handling the extension activation error - usually, it's a `string`, but in the case of a missing dependency, it is a JSON object - the parser was only handling the string case. __Fix:__ Implement a decoder to handle either case. Bubble up the activation error to the user. Related #2676 Related #1058
- Loading branch information
Showing
7 changed files
with
147 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
open Oni_Core; | ||
|
||
[@deriving show] | ||
type t = | ||
| Message(string) | ||
| MissingDependency(ExtensionId.t); | ||
|
||
let toString = | ||
fun | ||
| Message(str) => str | ||
| MissingDependency(extensionId) => | ||
Printf.sprintf( | ||
"Missing required extension: %s", | ||
ExtensionId.toString(extensionId), | ||
); | ||
|
||
module Decode = { | ||
open Json.Decode; | ||
let message = string |> map(str => Message(str)); | ||
|
||
let missingDependency = | ||
obj(({field, _}) => {field.required("dependency", ExtensionId.decode)}) | ||
|> map(extensionId => MissingDependency(extensionId)); | ||
|
||
let decode = | ||
one_of([ | ||
("message", message), | ||
("missingDependency", missingDependency), | ||
]); | ||
}; | ||
|
||
let decode = Decode.decode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,5 @@ let decode = | |
); | ||
|
||
let encode = Json.Encode.string; | ||
|
||
let toString = Fun.id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters