-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from HammerheadShark666/fix-null-issues
Fix null issues
- Loading branch information
Showing
5 changed files
with
39 additions
and
12 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
20 changes: 16 additions & 4 deletions
20
Microservice.CustomerAddress.Grpc/Helpers/EnvironmentVariables.cs
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 |
---|---|---|
@@ -1,8 +1,20 @@ | ||
namespace Microservice.CustomerAddress.Grpc.Helpers; | ||
using Microservice.CustomerAddress.Grpc.Helpers.Exceptions; | ||
|
||
namespace Microservice.CustomerAddress.Grpc.Helpers; | ||
|
||
public class EnvironmentVariablesHelper | ||
{ | ||
public static string JwtIssuer = Environment.GetEnvironmentVariable(Constants.JwtIssuer); | ||
public static string JwtAudience = Environment.GetEnvironmentVariable(Constants.JwtAudience); | ||
public static string JwtSymmetricSecurityKey = Environment.GetEnvironmentVariable(Constants.JwtSymmetricSecurityKey); | ||
public static string JwtIssuer => GetEnvironmentVariable(Constants.JwtIssuer); | ||
public static string JwtAudience => GetEnvironmentVariable(Constants.JwtAudience); | ||
public static string JwtSymmetricSecurityKey => GetEnvironmentVariable(Constants.JwtSymmetricSecurityKey); | ||
|
||
public static string GetEnvironmentVariable(string name) | ||
{ | ||
var variable = Environment.GetEnvironmentVariable(name); | ||
|
||
if (string.IsNullOrEmpty(variable)) | ||
throw new EnvironmentVariableNotFoundException($"Environment Variable Not Found: {name}."); | ||
|
||
return variable; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Microservice.CustomerAddress.Grpc/Helpers/Exceptions/EnvironmentVariableNotFoundException.cs
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,18 @@ | ||
namespace Microservice.CustomerAddress.Grpc.Helpers.Exceptions; | ||
|
||
public class EnvironmentVariableNotFoundException : Exception | ||
{ | ||
public EnvironmentVariableNotFoundException() | ||
{ | ||
} | ||
|
||
public EnvironmentVariableNotFoundException(string message) | ||
: base(message) | ||
{ | ||
} | ||
|
||
public EnvironmentVariableNotFoundException(string message, Exception inner) | ||
: base(message, inner) | ||
{ | ||
} | ||
} |
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