I have a problem. I'am catching an exception and i want to personalize the error message depending on the exception message.

so I want to check if my excpetion contains a certain string to dislay a specific message.
here is my code :

```
  try {
                    $em->persist($document);
                    $em->flush();
                } catch (\Exception $ex) {

                    $error = "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry";

                    throw new \Exception('Erreur lors de l\'upload du fichier');
                }

```

so i want to do something like

```
if($ex->getMessage() "contain" $error){throw new \Exception....}

```

but don't know how to do it

anyone have an idee ? 
thanks