Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better error handling when custom sobject is not found #14

Open
nimajalali opened this issue Feb 4, 2015 · 0 comments
Open

better error handling when custom sobject is not found #14

nimajalali opened this issue Feb 4, 2015 · 0 comments
Labels

Comments

@nimajalali
Copy link
Owner

Today if you attempt to interact with an SObject that doesn't exist in SalesForce the force package will panic.

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x48 pc=0x49f87]

goroutine 16 [running]:
runtime.panic(0x2a48a0, 0x4638e4)
    /usr/local/Cellar/go/1.3.3/libexec/src/pkg/runtime/panic.c:279 +0xf5
github.com/nimajalali/go-force/force.(*ForceApi).GetSObject(0xc208004180, 0x2eba50, 0xe, 0x51def0, 0xc208210000, 0x0, 0x0)
    /Users/njalali/Documents/go/src/github.com/nimajalali/go-force/force/sobjects.go:68 +0x137

Instead of a panic we should return a meaningful error. To do this we should verify the object metadata exists in the forceApi.apiSObjects map before trying to access it.

e.g.

data, ok := forceApi.apiSObjects["SOME_OBJECT_NAME"]
if !ok {
   return fmt.Errorf("Unable to find metadata for object: %s", "SOME_OBJECT_NAME")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant