@Override
    public boolean equals(Object o) {
        if (!(o instanceof ErrorMessage)) return false;

        ErrorMessage other = (ErrorMessage) o;

        if (this.code != other.code) return false;

        if (!this.message.equals(other.message)) return false;

        if (this.detailedMessage==null) return other.detailedMessage==null;
        if (other.detailedMessage==null) return false;

        return this.detailedMessage.equals(other.detailedMessage);
    }
@Test
    public void testErrorMessageEquality() {
        assertEquals(new ErrorMessage(17,"Message"),new ErrorMessage(17,"Message"));
        assertFalse(new ErrorMessage(16,"Message").equals(new ErrorMessage(17,"Message")));
        assertFalse(new ErrorMessage(17,"Message").equals(new ErrorMessage(17,"Other message")));
        assertFalse(new ErrorMessage(17,"Message").equals(new ErrorMessage(17,"Message","Detail")));
        assertFalse(new ErrorMessage(17,"Message","Detail").equals(new ErrorMessage(17,"Message")));
        assertEquals(new ErrorMessage(17,"Message","Detail"),new ErrorMessage(17,"Message","Detail",new Exception()));
        assertTrue(new ErrorMessage(17,"Message","Detail").equals(new ErrorMessage(17,"Message","Detail")));
        assertFalse(new ErrorMessage(17,"Message","Detail").equals(new ErrorMessage(17,"Message","Other detail")));
    }