# PetscTryMethod
Queries an object for a method added with `PetscObjectComposeFunction()`, if it exists then calls it. 
## Synopsis
```
#include "petsc/private/petscimpl.h"
PetscTryMethod(PetscObject obj,const char *name,(arg_types),(arg_value))
```

## Input Parameters

- ***obj -*** the object
- ***name -*** the name of the method, for example, "KSPGMRESSetRestart_C" for the function `KSPGMRESSetRestart()`
- ***arg_types -*** the argument types for the method, for example, (KSP,PetscInt)
- ***args -*** the arguements for the method, for example, (ksp,restart))





## Notes
The object is always the implicit first argument of the method and is not listed in arg_types or args

This does not return an error code, it is a macro that returns with an error code on error.

Use `PetscUseTypeMethod()` or `PetscTryTypeMethod()` to call functions that are included in the objects function table, the `ops` array
in the object.


## See Also
 `PetscUseMethod()`, `PetscCall()`, `PetscUseTypeMethod()`, `PetscTryTypeMethod()`, `PetscCheck()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petsc/private/petscimpl.h.html#PetscTryMethod">include/petsc/private/petscimpl.h</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petsc/private/petscimpl.h)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
