-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae9a0f5
commit 477d263
Showing
5 changed files
with
55 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package ami | ||
|
||
import "fmt" | ||
|
||
var ( | ||
// ErrorAsteriskConnTimeout error on connection timeout | ||
ErrorAsteriskConnTimeout = AMIErrorNew("Asterisk Server connection timeout") | ||
|
||
// ErrorAsteriskInvalidPrompt invalid prompt received from AMI server | ||
ErrorAsteriskInvalidPrompt = AMIErrorNew("Asterisk Server invalid prompt command line") | ||
|
||
// ErrorAsteriskNetwork networking errors | ||
ErrorAsteriskNetwork = AMIErrorNew("Network error") | ||
|
||
// ErrorAsteriskLogin AMI server login failed | ||
ErrorAsteriskLogin = AMIErrorNew("Asterisk Server login failed") | ||
|
||
// Error EOF | ||
ErrorEOF = "EOF" | ||
|
||
// Error I/O | ||
ErrorIO = "io: read/write on closed pipe" | ||
ErrorLoginFailed = "Failed login" | ||
) | ||
|
||
type AMIError struct { | ||
S string | ||
E string | ||
} | ||
|
||
func AMIErrorNew(message string) *AMIError { | ||
return &AMIError{S: message} | ||
} | ||
|
||
func (e *AMIError) AMIError(message string, args ...interface{}) *AMIError { | ||
t := fmt.Sprintf(message, args...) | ||
e.E = fmt.Sprintf(": %s", t) | ||
return e | ||
} | ||
|
||
func (e *AMIError) Error() string { | ||
return fmt.Sprintf("ami has error ocurred: %s%s", e.S, e.E) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.