Skip to content

Commit

Permalink
Catch type cast exception in Yaml/JSON provider
Browse files Browse the repository at this point in the history
  • Loading branch information
BredoGen committed Jun 1, 2022
1 parent edd4f39 commit 13dd4bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ Run Configuration support:
* Java Run Configurations (IDEA)
* Go Run Configurations (GoLand)

[GitHub](https://github.com/BredoGen/ProjectEnv)

## Settings
<kbd>Env Files</kbd> tool window > <kbd>Add your .env/json/yaml files</kbd>

For JSON/Yaml files only String:String maps are currently supported.

You can also toggle plugin features: <kbd>Env Files</kbd> tool window > <kbd>⚙️</kbd>:
* Enable in Terminal (requires terminal restart)
* Enable in Run Configurations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ class YamlFileProvider(private val params : Map<String, String>) : EnvFileProvid
result = Yaml().load(Files.readString(Paths.get(path)))
} catch (ex: IOException) {
throw EnvSourceException(ex)
} catch (ex: java.lang.ClassCastException) {
throw EnvSourceException("File content is not String:String map")
}
if (result == null) {
throw EnvSourceException("Cannot process file. Malformed format?")
}

return result
}
}

0 comments on commit 13dd4bc

Please sign in to comment.