function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jacob BarnettJacob Barnett 

Need help with "Invalid conversion from runtime type" error

I am getting an error that I can seem to figure out why it is failing validation. The error is System.TypeException: Invalid conversion from runtime type Utils_Api_WineOS.ErrorResponse to Utils_Api_WineOS.PostResponse

Here is the code snipet we have. This was built by an outside contractor we no longer have on the project and it's only now that it's erroring out.
    global abstract class BaseResponse {}

    global virtual class GetResponse extends BaseResponse {

        public List<SObject> records { get; set; }
        public Integer count { get {return this.records.size();} }
        public String next_records {
            get {
                if(this.records.size() >= 1) {
                    return 'before=' + records[records.size()-1].get('CreatedDate');
                }

                return null;
            }
        }

        public GetResponse() {
            this.records = new List<SObject>();
        }

        public GetResponse(System.RestResponse res, List<SObject> sObjs) {
            this.records = sObjs;
            res.statusCode = 200;
        }
    }

    global virtual class PostResponse extends BaseResponse {

        public List<SObject> records { get; set; }
        public Integer count { get {return this.records.size();} }

        public PostResponse() {
            this.records = new List<SObject>();
        }

        public PostResponse(System.RestResponse res, List<SObject> sObjs) {
            this.records = sObjs;
            res.statusCode = 200;
        }
    }

    global virtual class PatchResponse extends BaseResponse {

        public List<SObject> records { get; set; }
        public Integer count { get {return this.records.size();} }

        public PatchResponse() {
            this.records = new List<SObject>();
        }

        public PatchResponse(System.RestResponse res, List<SObject> sObjs) {
            this.records = sObjs;
            res.statusCode = 200;
        }
    }

    global virtual class DeleteResponse extends BaseResponse {

        public Boolean success { get; set; }

        public DeleteResponse(System.RestResponse res, Boolean success) {
            this.success = success;
            res.statusCode = 200;
        }
    }

    global virtual class StringResponse extends BaseResponse {

        public String data { get; set; }

        public StringResponse(System.RestResponse res, String data) {
            this.data = data;
            res.statusCode = 200;
        }
    }

    global class ErrorResponse extends BaseResponse {

        global String errorMessage {get; set;}

        public ErrorResponse() { }

        global ErrorResponse(System.RestResponse res, Integer errorCode, String errorMessage) {
            res.statusCode = errorCode;
            this.errorMessage = errorMessage;
        }
    }

I have the version of this on 45, the same as the dependant classes that use this class.