coreygriffin / go-freshservice Goto Github PK
View Code? Open in Web Editor NEWAn unofficial Go API client for the Freshservice API
Home Page: https://api.freshservice.com/
License: MIT License
An unofficial Go API client for the Freshservice API
Home Page: https://api.freshservice.com/
License: MIT License
v0.0.2
Any endpoint. I've tried Agent and Announcement
When running queries with invalid API credentials or bad request payloads, I would expect there to be some HTTP error returned (400, 401, 403, 404, etc) and sometimes a response body describing what went wrong. I've tried creating, listing and fetching individual entities, and it seems like in each case the HTTP error code and the error body is swallowed up internally in go-freshservice and is never available to me.
List queries return an empty slice []
, while individual queries return nil
. No errors are returned.
ctx := context.Background()
// I should get a 404 error here
api, err := fs.New(ctx, "fakedomain.freshservice.com", "badApikey", nil)
if err != nil {
log.Fatal(err)
}
agents, _, agentsError := api.Agents().List(ctx, nil)
// agents is []
// agentsError is nil
This lack of access to HTTP error codes or error bodies almost seems to be by design when I take a look at the source code.
Even if the ErrorResponse
interface is used conditionally in makeRequest
to decode the response body, we always return &res.Details
or &res.List
in the query functions like Agents().List
. Thus, the fields from ErrorResponse
, namely Description
and Errors
are never used for anything and are simply discarded. The HTTP response status code is also never returned from makeRequest
so that is definitely not available to me.
The existence of the ErrorResponse
interface clearly indicates that HTTP errors, or at least freshservice API errors, are supposed to be handled somehow. But I'm not seeing how that can be done the way the queries are written today.
Is there something here I have misunderstood or is the codebase simply at such an early stage that error handling was never prioritised and every query is assumed to run successfully?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.