avm2: Remove `From<Box<dyn std::error::Error>> for Error<'gc>`
This commit is contained in:
parent
cc531ff7db
commit
65ecb4fe8f
|
@ -691,7 +691,7 @@ fn attach_movie<'gc>(
|
||||||
.context
|
.context
|
||||||
.library
|
.library
|
||||||
.library_for_movie(movie_clip.movie().unwrap())
|
.library_for_movie(movie_clip.movie().unwrap())
|
||||||
.ok_or_else(|| "Movie is missing!".into())
|
.ok_or("Movie is missing!")
|
||||||
.and_then(|l| l.instantiate_by_export_name(export_name, activation.context.gc_context))
|
.and_then(|l| l.instantiate_by_export_name(export_name, activation.context.gc_context))
|
||||||
{
|
{
|
||||||
// Set name and attach to parent.
|
// Set name and attach to parent.
|
||||||
|
@ -860,7 +860,7 @@ pub fn duplicate_movie_clip_with_bias<'gc>(
|
||||||
.context
|
.context
|
||||||
.library
|
.library
|
||||||
.library_for_movie(movie)
|
.library_for_movie(movie)
|
||||||
.ok_or_else(|| "Movie is missing!".into())
|
.ok_or("Movie is missing!")
|
||||||
.and_then(|l| l.instantiate_by_id(id, activation.context.gc_context))
|
.and_then(|l| l.instantiate_by_id(id, activation.context.gc_context))
|
||||||
} else {
|
} else {
|
||||||
// Dynamically created clip; create a new empty movie clip.
|
// Dynamically created clip; create a new empty movie clip.
|
||||||
|
|
|
@ -131,9 +131,3 @@ impl<'gc> From<String> for Error<'gc> {
|
||||||
Error::RustError(val.into())
|
Error::RustError(val.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'gc> From<Box<dyn std::error::Error>> for Error<'gc> {
|
|
||||||
fn from(val: Box<dyn std::error::Error>) -> Error<'gc> {
|
|
||||||
Error::RustError(val)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -165,12 +165,12 @@ impl<'gc> MovieLibrary<'gc> {
|
||||||
&self,
|
&self,
|
||||||
id: CharacterId,
|
id: CharacterId,
|
||||||
gc_context: MutationContext<'gc, '_>,
|
gc_context: MutationContext<'gc, '_>,
|
||||||
) -> Result<DisplayObject<'gc>, Box<dyn std::error::Error>> {
|
) -> Result<DisplayObject<'gc>, &'static str> {
|
||||||
if let Some(character) = self.characters.get(&id) {
|
if let Some(character) = self.characters.get(&id) {
|
||||||
self.instantiate_display_object(character, gc_context)
|
self.instantiate_display_object(character, gc_context)
|
||||||
} else {
|
} else {
|
||||||
log::error!("Tried to instantiate non-registered character ID {}", id);
|
log::error!("Tried to instantiate non-registered character ID {}", id);
|
||||||
Err("Character id doesn't exist".into())
|
Err("Character id doesn't exist")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ impl<'gc> MovieLibrary<'gc> {
|
||||||
&self,
|
&self,
|
||||||
export_name: AvmString<'gc>,
|
export_name: AvmString<'gc>,
|
||||||
gc_context: MutationContext<'gc, '_>,
|
gc_context: MutationContext<'gc, '_>,
|
||||||
) -> Result<DisplayObject<'gc>, Box<dyn std::error::Error>> {
|
) -> Result<DisplayObject<'gc>, &'static str> {
|
||||||
if let Some(character) = self.export_characters.get(export_name, false) {
|
if let Some(character) = self.export_characters.get(export_name, false) {
|
||||||
self.instantiate_display_object(character, gc_context)
|
self.instantiate_display_object(character, gc_context)
|
||||||
} else {
|
} else {
|
||||||
|
@ -188,7 +188,7 @@ impl<'gc> MovieLibrary<'gc> {
|
||||||
"Tried to instantiate non-registered character {}",
|
"Tried to instantiate non-registered character {}",
|
||||||
export_name
|
export_name
|
||||||
);
|
);
|
||||||
Err("Character id doesn't exist".into())
|
Err("Character id doesn't exist")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ impl<'gc> MovieLibrary<'gc> {
|
||||||
&self,
|
&self,
|
||||||
character: &Character<'gc>,
|
character: &Character<'gc>,
|
||||||
gc_context: MutationContext<'gc, '_>,
|
gc_context: MutationContext<'gc, '_>,
|
||||||
) -> Result<DisplayObject<'gc>, Box<dyn std::error::Error>> {
|
) -> Result<DisplayObject<'gc>, &'static str> {
|
||||||
match character {
|
match character {
|
||||||
Character::Bitmap(bitmap) => Ok(bitmap.instantiate(gc_context)),
|
Character::Bitmap(bitmap) => Ok(bitmap.instantiate(gc_context)),
|
||||||
Character::EditText(edit_text) => Ok(edit_text.instantiate(gc_context)),
|
Character::EditText(edit_text) => Ok(edit_text.instantiate(gc_context)),
|
||||||
|
@ -209,7 +209,7 @@ impl<'gc> MovieLibrary<'gc> {
|
||||||
Character::Avm2Button(button) => Ok(button.instantiate(gc_context)),
|
Character::Avm2Button(button) => Ok(button.instantiate(gc_context)),
|
||||||
Character::Text(text) => Ok(text.instantiate(gc_context)),
|
Character::Text(text) => Ok(text.instantiate(gc_context)),
|
||||||
Character::Video(video) => Ok(video.instantiate(gc_context)),
|
Character::Video(video) => Ok(video.instantiate(gc_context)),
|
||||||
_ => Err("Not a DisplayObject".into()),
|
_ => Err("Not a DisplayObject"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue