-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
dc72e49
commit 536a053
Showing
5 changed files
with
81 additions
and
12 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
android/src/main/java/com/drpogodin/reactnativeaudio/Errors.java
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,55 @@ | ||
package com.drpogodin.reactnativeaudio; | ||
|
||
import android.util.Log; | ||
import com.facebook.react.bridge.Promise; | ||
|
||
public enum Errors { | ||
NOT_IMPLEMENTED("Not implemented"); | ||
|
||
private String message; | ||
public static final String LOGTAG = "RN_AUDIO"; | ||
|
||
Errors(String message) { | ||
this.message = message; | ||
} | ||
|
||
public Error getError() { | ||
return new Error(this.getMessage()); | ||
} | ||
|
||
public Exception getException() { | ||
return new Exception(this.getMessage()); | ||
} | ||
|
||
public String getMessage() { | ||
return this.message; | ||
} | ||
|
||
public Errors log() { | ||
Log.e(Errors.LOGTAG, this.getMessage()); | ||
return this; | ||
} | ||
|
||
public Errors log(Exception e) { | ||
Log.e(Errors.LOGTAG, e.toString()); | ||
return this.log(); | ||
} | ||
|
||
public void reject(Promise promise) { | ||
if (promise != null) { | ||
promise.reject(this.toString(), this.getMessage(), this.getError()); | ||
} | ||
} | ||
|
||
public void reject(Promise promise, String details) { | ||
if (promise != null) { | ||
String message = this.getMessage(); | ||
if (details != null) message += ": " + details; | ||
promise.reject(this.toString(), message, this.getError()); | ||
} | ||
} | ||
|
||
public String toString() { | ||
return Errors.LOGTAG + ":" + this.name(); | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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