'C# how to deal with integer overflows when returning status code from application in unix environment

I have a program similar to this

public static class Program
{
    public const int BAD_SCRIPT = 1337;

    private static async Task<int> main(string[] args)
    {
        string script = ParseArguments(args);
        return await GetSomeResult(script);
    }
    
    private static async Task<int> GetSomeResult(string script)
    {
        return string.IsNullOrEmpty(script) ? BAD_SCRIPT : 0;
    }
}

This works fine on the windows environment and returns the expected error. However, in Unix it returns the modulus of 256 due to integer overflow. My question to you is how do I deal with this scenario? This causes the API request to return a wrong error.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source