modified the error handling to create new Error structs so that tests can compare string outputs