Comments (5)
Just wrapping your "client" code with the usual try/catch/finally statements should work.
For example:
$osm = new Services_OpenStreetMap();
try {
var_dump($osm->getCoordsOfPlace("Nena, Irelande"));
} catch(Exception $ex) {
var_dump ($ex->getMessage());
} finally {
echo "yay!\n";
}
from services_openstreetmap.
Ok, this method works, but it is pretty hardcore...
It would be better, if for example $changeset->commit() would return a statuscode/message with predefined status levels.
from services_openstreetmap.
I don't know how catching exceptions in PHP could be called hardcode, but I think you're correct that there are some places in Services_Openstreetmap where returning a simple value or array of values would be better than throwing a new exception.
Strictly speaking, exceptions should be for "exceptional scenarios" - something not easily predictable happening, for example.
So in the example above, getCoordsOfPlace quite possibly should be returning false when it can't get the lat/lon for a named place that doesn't exist. BUT if there are connectivity issues, exceptions should be thrown.
Are there any specific cases where you think it would be easier for you that exceptions weren't being thrown? I don't want to start making changes that would break compatibility but I will consider this in future.
from services_openstreetmap.
Hi Ken,
you are are right, that for connectivity issues, etc it is best to throw an exception.
But I miss feedback for cases, where OSM throws an error. For example a $changeset->commit() should return an info, if the process was succesful or not.
from services_openstreetmap.
Hi @sascha-hendel, the changeset commit method now finally returns true if changes have been successfully applied.
(The API itself specifies that nothing is returned upon successful closing of a changeset, so this is just a check for a Response Code of 200)
Is there anything else about this that you might like to see improved?
from services_openstreetmap.
Related Issues (20)
- Can't find HTTP/Request2.php HOT 7
- Allowing to create/change two tags with the same value HOT 2
- Changeset and setTag HOT 5
- Removing Tag? HOT 5
- tests/TagsWithSameValueTest.php not adressing the problem HOT 1
- Use https for openstreetmap.org servers HOT 1
- Wildcard search HOT 3
- Again remove Tag(s)? HOT 6
- Disable verify ssl validation HOT 9
- Split out documentation from README into separate files. HOT 1
- Expand to get details of multiple users.
- Expand Services_Openstreetmap_Config object
- Add support for retrieving notes via the /api/0.6/notes/search endpoint. HOT 4
- Add checks that lenghts of keys and values on objects don't exceed 255 characters each HOT 4
- Removing tags is not working
- Dependabot can't parse your composer.json
- Dependabot can't resolve your PHP dependency files
- new Way create method and building creation using way(area polygon) code sample
- Need installation instructions HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from services_openstreetmap.