-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
35 lines (29 loc) · 909 Bytes
/
errors.go
File metadata and controls
35 lines (29 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Package altinapi — Resmi altinapi Go SDK.
//
// REST + WebSocket erişimi için tek pakette istemci.
// Detaylar: https://altinapi.com/docs
package altinapi
import "fmt"
// Error — altinapi SDK tarafından döndürülen hata.
// StatusCode 0 ise ağ hatası, aksi halde HTTP durum kodu.
type Error struct {
Message string
StatusCode int
// Cause altta yatan hatayı tutar (errors.Is/As ile kullanılabilir).
Cause error
}
// Error — error interface implementasyonu.
func (e *Error) Error() string {
if e.StatusCode > 0 {
return fmt.Sprintf("[%d] %s", e.StatusCode, e.Message)
}
return e.Message
}
// Unwrap — errors.Is / errors.As desteği.
func (e *Error) Unwrap() error {
return e.Cause
}
// newError — internal kullanım için kısa kurucu.
func newError(message string, status int, cause error) *Error {
return &Error{Message: message, StatusCode: status, Cause: cause}
}